class CustomEditor ( SimpleEditor, IValueChangeListener ): """ Custom style editor for a button, which can contain an image. """ #--------------------------------------------------------------------------- # Finishes initializing the editor by creating the underlying toolkit # widget: #--------------------------------------------------------------------------- def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ # FIXME: We ignore orientation, width_padding and height_padding. factory = self.factory style = factory.style label = str(self.string_value(factory.label)) image = factory.image if style == 'checkbox': self.control = CheckBox(label) self.control.setImmediate(True) self.control.addListener(self, IClickListener) if image is not None: self.control.setIcon(image.create_icon()) elif style == 'radio': self.control = OptionGroup('', [label]) self.control.setNullSelectionAllowed(True) self.control.setImmediate(True) self.control.addListener(self, IValueChangeListener) if image is not None: self.control.setItemIcon(label, image.create_icon()) elif style == 'toolbar': self.control = NativeButton(label) self.control.addListener(self, IClickListener) if image is not None: self.control.setIcon(image.create_icon()) self.set_tooltip() #--------------------------------------------------------------------------- # Handles the user clicking the radion button: #--------------------------------------------------------------------------- def valueChange(self, event): self.update_object()