class CustomEditor(SimpleEditor): """ 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. """ from pyface.image_button import ImageButton factory = self.factory if self.factory.label: label = self.factory.label else: label = self.item.get_label(self.ui) self._control = ImageButton(parent, label=self.string_value(label), image=factory.image, style=factory.style, orientation=factory.orientation, width_padding=factory.width_padding, height_padding=factory.height_padding) self.control = self._control.control self._control.on_trait_change(self.update_object, 'clicked', dispatch='ui') self.sync_value(self.factory.label_value, 'label', 'from') self.set_tooltip() #------------------------------------------------------------------------- # Disposes of the contents of an editor: #------------------------------------------------------------------------- def dispose(self): """ Disposes of the contents of an editor. """ self._control.on_trait_change(self.update_object, 'clicked', remove=True) super(CustomEditor, self).dispose()
class CustomEditor(SimpleEditor): """ 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. """ from pyface.image_button import ImageButton factory = self.factory if self.factory.label: label = self.factory.label else: label = self.item.get_label(self.ui) self._control = ImageButton( parent, label=self.string_value(label), image=factory.image, style=factory.style, orientation=factory.orientation, width_padding=factory.width_padding, height_padding=factory.height_padding ) self.control = self._control.control self._control.on_trait_change(self.update_object, 'clicked', dispatch='ui') self.sync_value(self.factory.label_value, 'label', 'from') self.set_tooltip() #------------------------------------------------------------------------- # Disposes of the contents of an editor: #------------------------------------------------------------------------- def dispose(self): """ Disposes of the contents of an editor. """ self._control.on_trait_change(self.update_object, 'clicked', remove=True) super(CustomEditor, self).dispose()