/usr/share/pyshared/PythonCard/components/radiogroup.py is in python-pythoncard 0.8.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | """
__version__ = "$Revision: 1.25 $"
__date__ = "$Date: 2004/05/13 02:40:24 $"
"""
import wx
from PythonCard import event, widget
from list import ContainerMixin
class RadioGroupSelectEvent(event.SelectEvent):
binding = wx.EVT_RADIOBOX
id = wx.wxEVT_COMMAND_RADIOBOX_SELECTED
RadioGroupEvents = (RadioGroupSelectEvent,)
class RadioGroupSpec(widget.WidgetSpec):
def __init__(self):
events = list(RadioGroupEvents)
## events = [event.SelectEvent]
attributes = {
'label' : { 'presence' : 'optional', 'default' : '' },
'items' : { 'presence' : 'optional', 'default' : ['one'] },
'stringSelection' : { 'presence' : 'optional', 'default' : 'one' },
'layout' : { 'presence' : 'optional', 'default' : 'vertical', 'values' : [ 'horizontal', 'vertical' ] },
'max' : { 'presence' : 'optional', 'default' : 1 }
# KEA we can't control the border of a wxRadioBox as far as I can tell
#'border' : { 'presence' : 'optional', 'default' : None }
}
widget.WidgetSpec.__init__( self, 'RadioGroup', 'Widget', events, attributes )
class RadioGroup(widget.Widget, wx.RadioBox, ContainerMixin):
"""
A group of radio buttons.
"""
_spec = RadioGroupSpec()
def __init__(self, aParent, aResource):
wx.RadioBox.__init__(
self,
aParent,
widget.makeNewId(aResource.id),
aResource.label,
aResource.position,
aResource.size,
aResource.items,
aResource.max,
self.__getLayout(aResource.layout) | \
wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_SIBLINGS,
name=aResource.name
)
widget.Widget.__init__(self, aParent, aResource)
self._labels = aResource.items
self._layout = aResource.layout
self._max = aResource.max
if aResource.stringSelection:
self._setStringSelection(aResource.stringSelection)
self._bindEvents(event.WIDGET_EVENTS + RadioGroupEvents)
def __getLayout(self, aString):
if aString == 'vertical':
return wx.RA_SPECIFY_COLS
elif aString == 'horizontal':
return wx.RA_SPECIFY_ROWS
else:
raise 'invalid RadioGroup.layout value: ', aString
def _getItems(self):
return self._labels
# KEA 2004-04-23
# I could probably manually call SetItemLabel(n, string)
# to replace all the radio button lables but only
# if there was the same number of items as radio buttons
def _setItems(self, aList):
raise NotImplementedError
def _getLayout(self):
return self._layout
def _setLayout(self, aString):
raise AttributeError, "layout attribute is read-only"
def _getMax(self):
return self._max
def _setMax(self, aMax):
raise AttributeError, "max attribute is read-only"
items = property(_getItems, _setItems)
label = property(wx.RadioBox.GetLabel, wx.RadioBox.SetLabel)
layout = property(_getLayout, _setLayout)
max = property(_getMax, _setMax)
import sys
from PythonCard import registry
registry.Registry.getInstance().register(sys.modules[__name__].RadioGroup)
|