Mercurial > fife-parpg
comparison engine/extensions/pychan/widgets/radiobutton.py @ 248:a2d5e2721489
widgets.py split up.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 26 Mar 2009 16:20:16 +0000 |
parents | |
children | 1cc51d145af9 |
comparison
equal
deleted
inserted
replaced
247:040387b7167f | 248:a2d5e2721489 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 from common import * | |
4 from basictextwidget import BasicTextWidget | |
5 | |
6 class RadioButton(BasicTextWidget): | |
7 """ | |
8 A basic radiobutton (an exclusive checkbox). | |
9 | |
10 New Attributes | |
11 ============== | |
12 | |
13 - marked: Boolean: Whether the checkbox is checked or not. | |
14 - group: String: All RadioButtons with the same group name | |
15 can only be checked exclusively. | |
16 | |
17 Data | |
18 ==== | |
19 The marked status can be read and set via L{distributeData} and L{collectData} | |
20 """ | |
21 | |
22 ATTRIBUTES = BasicTextWidget.ATTRIBUTES + [BoolAttr('marked'),Attr('group')] | |
23 | |
24 def __init__(self,group="_no_group_",**kwargs): | |
25 self.real_widget = fife.RadioButton() | |
26 super(RadioButton,self).__init__(**kwargs) | |
27 | |
28 self.group = group | |
29 | |
30 # Prepare Data collection framework | |
31 self.accepts_data = True | |
32 self._realGetData = self._isMarked | |
33 self._realSetData = self._setMarked | |
34 | |
35 # Initial data stuff inherited. | |
36 | |
37 def _isMarked(self): return self.real_widget.isSelected() | |
38 def _setMarked(self,mark): self.real_widget.setSelected(mark) | |
39 marked = property(_isMarked,_setMarked) | |
40 | |
41 def _setGroup(self,group): self.real_widget.setGroup(group) | |
42 def _getGroup(self): return self.real_widget.getGroup() | |
43 group = property(_getGroup,_setGroup) | |
44 | |
45 def resizeToContent(self,recurse=True): | |
46 self.width = self.real_font.getWidth(_text2gui(self.text)) + 35# Size of the Checked box? | |
47 self.height = self.real_font.getHeight() |