Пример #1
0
class _TitleEditor(Editor):

    def init(self, parent):
        """Finishes initializing the editor by creating the underlying toolkit
        widget.
        """
        self._control = HeadingText(parent=parent, create=False)
        self._control.create()
        self.control = self._control.control
        self.set_tooltip()

    def update_editor(self):
        """Updates the editor when the object trait changes external to the
        editor.
        """
        self._control.text = self.str_value

    def dispose(self):
        """Cleanly dispose of the editor.

        This ensures that the wrapped Pyface Widget is cleaned-up.
        """
        if self._control is not None:
            self._control.destroy()
        super().dispose()
Пример #2
0
class SimpleEditor(Editor):
    def init(self, parent):
        """Finishes initializing the editor by creating the underlying toolkit
        widget.
        """
        if isinstance(parent, QtGui.QLayout):
            parent = parent.parentWidget()
        self._control = HeadingText(parent=parent, create=False)
        self._control.create()
        self.control = self._control.control
        if self.factory.allow_selection:
            flags = (self.control.textInteractionFlags()
                     | QtCore.Qt.TextInteractionFlag.TextSelectableByMouse)
            self.control.setTextInteractionFlags(flags)
        self.set_tooltip()

    def update_editor(self):
        """Updates the editor when the object trait changes external to the
        editor.
        """
        self._control.text = self.str_value

    def dispose(self):
        """Cleanly dispose of the editor.

        This ensures that the wrapped Pyface Widget is cleaned-up.
        """
        if self._control is not None:
            self._control.destroy()
        super().dispose()
Пример #3
0
 def init(self, parent):
     """Finishes initializing the editor by creating the underlying toolkit
     widget.
     """
     self._control = HeadingText(parent=parent, create=False)
     self._control.create()
     self.control = self._control.control
     self.set_tooltip()
Пример #4
0
def heading_text(*args, create=False, **kw):
    """Create a Pyface HeadingText control."""
    global HeadingText

    if HeadingText is None:
        from pyface.api import HeadingText

    widget = HeadingText(*args, create=create, **kw)
    widget.create()
    return widget
Пример #5
0
 def init(self, parent):
     """Finishes initializing the editor by creating the underlying toolkit
     widget.
     """
     if isinstance(parent, QtGui.QLayout):
         parent = parent.parentWidget()
     self._control = HeadingText(parent=parent, create=False)
     self._control.create()
     self.control = self._control.control
     if self.factory.allow_selection:
         flags = (self.control.textInteractionFlags()
                  | QtCore.Qt.TextInteractionFlag.TextSelectableByMouse)
         self.control.setTextInteractionFlags(flags)
     self.set_tooltip()
Пример #6
0
    def create_page(self, parent):
        """ Creates the wizard page. """

        panel = wx.Panel(parent, -1, style=wx.CLIP_CHILDREN)
        sizer = wx.BoxSizer(wx.VERTICAL)
        panel.SetSizer(sizer)
        panel.SetAutoLayout(True)

        # The 'pretty' title bar ;^)
        title = HeadingText(panel, text=self.text)
        sizer.Add(title.control, 0, wx.EXPAND | wx.BOTTOM, 5)

        # The editor for the quantity properties.
        view = View(
            [ 'value{Value}',
              'units{Units}',
              'value_unit_family{Measure of}']
        )

        ui = self.obj.edit_traits(parent=panel, view=view, kind='subpanel')
        sizer.Add(ui.control, 1, wx.EXPAND)

        # A panel to display any error messages.
        self._error_panel = error_panel = self._create_error_panel(panel)
        sizer.Add(error_panel, 0, wx.EXPAND | wx.TOP | wx.LEFT, 5)

        # Resize the panel to match the sizer's minimum size.
        sizer.Fit(panel)

        # Check if the default values constitute a valid quantity.
        self._validate()

        self.obj.on_trait_change( self._on_units_changed, 'units' )
        self.obj.on_trait_change( self._on_family_changed, 'value_unit_family' )
        return panel
Пример #7
0
    def _create_rhs(self, parent):
        """ Creates the panel containing the selected preference page. """

        panel = wx.Panel(parent, -1, style=wx.CLIP_CHILDREN)
        sizer = wx.BoxSizer(wx.VERTICAL)
        panel.SetSizer(sizer)
        panel.SetAutoLayout(True)

        # The 'pretty' title bar ;^)
        self.__title = HeadingText(panel)
        sizer.Add(self.__title.control, 0,
                  wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT, 5)

        # The preference page of the node currently selected in the tree.
        self._layered_panel = LayeredPanel(panel, min_width=-1, min_height=-1)
        sizer.Add(self._layered_panel.control, 1,
                  wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 5)

        # The 'Restore Defaults' button etc.
        buttons = self._create_page_buttons(panel)
        sizer.Add(buttons, 0, wx.ALIGN_RIGHT | wx.TOP | wx.RIGHT, 5)

        # A separator.
        line = wx.StaticLine(panel, -1)
        sizer.Add(line, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 5)

        # Resize the panel to fit the sizer's minimum size.
        sizer.Fit(panel)

        return panel
Пример #8
0
def heading_text(*args, **kw):
    """Create a Pyface HeadingText control.
    """
    global HeadingText

    if HeadingText is None:
        from pyface.api import HeadingText

    return HeadingText(*args, **kw)
Пример #9
0
    def create_page(self, parent):
        """ Creates the wizard page. """

        # FIXME: implement support for the size trait.

        panel = wx.Panel(parent, -1, style=wx.CLIP_CHILDREN)
        sizer = wx.BoxSizer(wx.VERTICAL)
        panel.SetSizer(sizer)
        panel.SetAutoLayout(True)

        # The 'pretty' heading ;^)
        if len(self.heading) > 0:
            title = HeadingText(panel, text=self.heading)
            sizer.Add(title.control, 0, wx.EXPAND | wx.BOTTOM, 5)

        if len(self.subheading) > 0:
            subtitle = wx.StaticText(panel, -1, self.subheading)
            sizer.Add(subtitle, 0, wx.EXPAND | wx.BOTTOM, 5)

        # The page content.
        content = self._create_page_content(panel)
        sizer.Add(content, 1, wx.EXPAND)

        return panel
Пример #10
0
    def _create_contents(self, parent):
        """ Create the editor. """

        self._label = HeadingText(parent, text="Hello World")

        return self._label.control