Mercurial > fife-parpg
comparison engine/python/fife/extensions/pychan/widgets/radiobutton.py @ 378:64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Jan 2010 23:34:52 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
377:fe6fb0e0ed23 | 378:64738befdf3b |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 # #################################################################### | |
4 # Copyright (C) 2005-2009 by the FIFE team | |
5 # http://www.fifengine.de | |
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 RadioButton(BasicTextWidget): | |
28 """ | |
29 A basic radiobutton (an exclusive checkbox). | |
30 | |
31 New Attributes | |
32 ============== | |
33 | |
34 - marked: Boolean: Whether the checkbox is checked or not. | |
35 - group: String: All RadioButtons with the same group name | |
36 can only be checked exclusively. | |
37 | |
38 Data | |
39 ==== | |
40 The marked status can be read and set via L{distributeData} and L{collectData} | |
41 """ | |
42 | |
43 ATTRIBUTES = BasicTextWidget.ATTRIBUTES + [BoolAttr('marked'),Attr('group')] | |
44 | |
45 def __init__(self,group="_no_group_",**kwargs): | |
46 self.real_widget = fife.RadioButton() | |
47 super(RadioButton,self).__init__(**kwargs) | |
48 | |
49 self.group = group | |
50 | |
51 # Prepare Data collection framework | |
52 self.accepts_data = True | |
53 self._realGetData = self._isMarked | |
54 self._realSetData = self._setMarked | |
55 | |
56 # Initial data stuff inherited. | |
57 | |
58 def _isMarked(self): return self.real_widget.isSelected() | |
59 def _setMarked(self,mark): self.real_widget.setSelected(mark) | |
60 marked = property(_isMarked,_setMarked) | |
61 | |
62 def _setGroup(self,group): self.real_widget.setGroup(group) | |
63 def _getGroup(self): return self.real_widget.getGroup() | |
64 group = property(_getGroup,_setGroup) | |
65 | |
66 def resizeToContent(self,recurse=True): | |
67 self.width = self.real_font.getWidth(text2gui(self.text)) + 35# Size of the Checked box? | |
68 self.height = self.real_font.getHeight() |