Package fife :: Package extensions :: Package pychan :: Package widgets' :: Module checkbox
[hide private]
[frames] | no frames]

Source Code for Module fife.extensions.pychan.widgets'.checkbox

  1  # -*- coding: utf-8 -*- 
  2   
  3  # #################################################################### 
  4  #  Copyright (C) 2005-2011 by the FIFE team 
  5  #  http://www.fifengine.net 
  6  #  This file is part of FIFE. 
  7  # 
  8  #  FIFE is free software; you can redistribute it and/or 
  9  #  modify it under the terms of the GNU Lesser General Public 
 10  #  License as published by the Free Software Foundation; either 
 11  #  version 2.1 of the License, or (at your option) any later version. 
 12  # 
 13  #  This library is distributed in the hope that it will be useful, 
 14  #  but WITHOUT ANY WARRANTY; without even the implied warranty of 
 15  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 16  #  Lesser General Public License for more details. 
 17  # 
 18  #  You should have received a copy of the GNU Lesser General Public 
 19  #  License along with this library; if not, write to the 
 20  #  Free Software Foundation, Inc., 
 21  #  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA 
 22  # #################################################################### 
 23   
 24  from common import * 
 25  from basictextwidget import BasicTextWidget 
 26   
27 -class CheckBox(BasicTextWidget):
28 """ 29 A basic checkbox. 30 31 New Attributes 32 ============== 33 34 - marked: Boolean value, whether the checkbox is checked or not. 35 36 Data 37 ==== 38 The marked status can be read and set via L{distributeData} and L{collectData} 39 """ 40 41 ATTRIBUTES = BasicTextWidget.ATTRIBUTES + [ BoolAttr('marked') ] 42 43 DEFAULT_MARKED = False 44
45 - def __init__(self, 46 parent = None, 47 name = None, 48 size = None, 49 min_size = None, 50 max_size = None, 51 helptext = None, 52 position = None, 53 style = None, 54 hexpand = None, 55 vexpand = None, 56 font = None, 57 base_color = None, 58 background_color = None, 59 foreground_color = None, 60 selection_color = None, 61 border_size = None, 62 position_technique = None, 63 is_focusable = None, 64 comment = None, 65 margins = None, 66 text = None, 67 marked = None):
68 69 self.real_widget = fife.CheckBox() 70 self.marked = self.DEFAULT_MARKED 71 super(CheckBox,self).__init__(parent=parent, 72 name=name, 73 size=size, 74 min_size=min_size, 75 max_size=max_size, 76 helptext=helptext, 77 position=position, 78 style=style, 79 hexpand=hexpand, 80 vexpand=vexpand, 81 font=font, 82 base_color=base_color, 83 background_color=background_color, 84 foreground_color=foreground_color, 85 selection_color=selection_color, 86 border_size=border_size, 87 position_technique=position_technique, 88 is_focusable=is_focusable, 89 comment=comment, 90 margins=margins, 91 text=text) 92 if marked is not None: 93 self.marked = marked 94 95 # Prepare Data collection framework 96 self.accepts_data = True 97 self._realGetData = self._isMarked 98 self._realSetData = self._setMarked
99
100 - def clone(self, prefix):
101 checkboxClone = CheckBox(None, 102 self._createNameWithPrefix(prefix), 103 self.size, 104 self.min_size, 105 self.max_size, 106 self.helptext, 107 self.position, 108 self.style, 109 self.hexpand, 110 self.vexpand, 111 self.font, 112 self.base_color, 113 self.background_color, 114 self.foreground_color, 115 self.selection_color, 116 self.border_size, 117 self.position_technique, 118 self.is_focusable, 119 self.comment, 120 self.margins, 121 self.text, 122 self.marked) 123 return checkboxClone
124
125 - def _isMarked(self): return self.real_widget.isSelected()
126 - def _setMarked(self,mark): self.real_widget.setSelected(mark)
127 marked = property(_isMarked,_setMarked)
128