def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ super( RadioEditor, self ).init( parent ) self.control = OptionGroup() self.control.setImmediate(True) self.control.setMultiSelect(False) self.control.addListener(self, IValueChangeListener) self.rebuild_editor()
def __init__(self): super(OptionGroupsExample, self).__init__() self.setSpacing(True) # 'Shorthand' constructor - also supports data binding using Containers citySelect = OptionGroup('Please select a city', self._cities) # user can not 'unselect' citySelect.setNullSelectionAllowed(False) # select this by default citySelect.select('Berlin') # send the change to the server at once citySelect.setImmediate(True) # react when the user selects something citySelect.addListener(self, IValueChangeListener) self.addComponent(citySelect) self.addComponent( Label('<h3>Multi-selection</h3>', Label.CONTENT_XHTML)) # Create the multiselect option group # 'Shorthand' constructor - also supports data binding using Containers citySelect = OptionGroup('Please select cities', self._cities) citySelect.setMultiSelect(True) # FIXME: multi-select # user can not 'unselect' citySelect.setNullSelectionAllowed(False) # select this by default citySelect.select('Berlin') # send the change to the server at once citySelect.setImmediate(True) # react when the user selects something citySelect.addListener(self, IValueChangeListener) self.addComponent(citySelect)
class SplitPanelPositioningExample(VerticalLayout): def __init__(self): super(SplitPanelPositioningExample, self).__init__() self.setStyleName('split-panel-positioning-example') self.setSpacing(True) controls = HorizontalLayout() controls.setSpacing(True) self.addComponent(controls) self._verticalSplitPanel = VerticalSplitPanel() self._verticalSplitPanel.setSplitPosition(100, ISizeable.UNITS_PIXELS) self._verticalSplitPanel.setLocked(True) self._verticalSplitPanel.setHeight('450px') self._verticalSplitPanel.setWidth('100%') self.addComponent(self._verticalSplitPanel) # Add some content to the top topArea = Label() topArea.setStyleName('top-area') topArea.addStyleName('measured-from-top') topArea.setSizeFull() self._verticalSplitPanel.addComponent(topArea) # Add a horizontal split panel in the bottom area self._horizontalSplitPanel = HorizontalSplitPanel() self._horizontalSplitPanel.setSplitPosition(30, ISizeable.UNITS_PERCENTAGE) self._horizontalSplitPanel.setSizeFull() self._horizontalSplitPanel.setLocked(True) self._verticalSplitPanel.addComponent(self._horizontalSplitPanel) # Add some content to the left and right sides of the vertical layout leftArea = Label() leftArea.setStyleName('left-area') leftArea.addStyleName('measured-from-left') leftArea.setSizeFull() self._horizontalSplitPanel.addComponent(leftArea) rightArea = Label() rightArea.setStyleName('right-area') rightArea.setSizeFull() self._horizontalSplitPanel.addComponent(rightArea) # Allow user to set the splitter positioning self._measurePositionFromLeft = OptionGroup('Horizontal split position', ['30% from left', '30% from right']) self._measurePositionFromLeft.setValue('30% from left') self._measurePositionFromLeft.setImmediate(True) l = LeftRightListener(self, leftArea, rightArea) self._measurePositionFromLeft.addListener(l, IValueChangeListener) controls.addComponent(self._measurePositionFromLeft) controls.setComponentAlignment(self._measurePositionFromLeft, Alignment.MIDDLE_CENTER) self._measurePositionFromTop = OptionGroup('Vertical split position', ['100px from top', '100px from bottom']) self._measurePositionFromTop.setValue('100px from top') self._measurePositionFromTop.setImmediate(True) l = TopBottomListener(self, leftArea, rightArea, topArea) self._measurePositionFromTop.addListener(l, IValueChangeListener) controls.addComponent(self._measurePositionFromTop) controls.setComponentAlignment(self._measurePositionFromTop, Alignment.MIDDLE_CENTER)
class RadioEditor ( BaseEditor, IValueChangeListener ): """ Enumeration editor, used for the "custom" style, that displays radio buttons. """ # Is the button layout row-major or column-major? row_major = Bool( False ) #--------------------------------------------------------------------------- # Finishes initializing the editor by creating the underlying toolkit # widget: #--------------------------------------------------------------------------- def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ super( RadioEditor, self ).init( parent ) self.control = OptionGroup() self.control.setImmediate(True) self.control.setMultiSelect(False) self.control.addListener(self, IValueChangeListener) self.rebuild_editor() #--------------------------------------------------------------------------- # Handles the user clicking one of the 'custom' radio buttons: #--------------------------------------------------------------------------- def valueChange(self, event): v = event.getProperty().getValue() self.value = self.mapping[v] # def update_object ( self, index ): # """ Handles the user clicking one of the custom radio buttons. # """ # try: # self.value = self.mapping[self.names[index]] # except: # pass #--------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: #--------------------------------------------------------------------------- def update_editor ( self ): """ Updates the editor when the object trait changes externally to the editor. """ value = self.value label = value#self.string_value(value, capitalize) self.control.select( str(label) ) #--------------------------------------------------------------------------- # Rebuilds the contents of the editor whenever the original factory # object's 'values' trait changes: #--------------------------------------------------------------------------- def rebuild_editor ( self ): """ Rebuilds the contents of the editor whenever the original factory object's **values** trait changes. """ # Clear any existing content: self.control.removeAllItems() # Get the current trait value: cur_name = self.str_value # Create a sizer to manage the radio buttons: names = self.names for name in names: label = name#self.string_value(name, capitalize) self.control.addItem( str(label) ) label = cur_name#self.string_value(cur_name, capitalize) self.control.select( str(label) )
def __init__(self): super(OptionGroupsExample, self).__init__() self.setSpacing(True) # 'Shorthand' constructor - also supports data binding using Containers citySelect = OptionGroup('Please select a city', self._cities) # user can not 'unselect' citySelect.setNullSelectionAllowed(False) # select this by default citySelect.select('Berlin') # send the change to the server at once citySelect.setImmediate(True) # react when the user selects something citySelect.addListener(self, IValueChangeListener) self.addComponent(citySelect) self.addComponent(Label('<h3>Multi-selection</h3>', Label.CONTENT_XHTML)) # Create the multiselect option group # 'Shorthand' constructor - also supports data binding using Containers citySelect = OptionGroup('Please select cities', self._cities) citySelect.setMultiSelect(True) # FIXME: multi-select # user can not 'unselect' citySelect.setNullSelectionAllowed(False) # select this by default citySelect.select('Berlin') # send the change to the server at once citySelect.setImmediate(True) # react when the user selects something citySelect.addListener(self, IValueChangeListener) self.addComponent(citySelect)