Beispiel #1
0
    def test_dispose_inner_ui(self):
        obj = DummyObject()
        view = View(
            Group(
                Item(
                    "number",
                    editor=BasicEditorFactory(klass=EditorWithCustomWidget),
                ), ), )
        ui = obj.edit_traits(view=view)
        editor, = ui.get_editors("number")

        gui = GUI()
        with ensure_destroyed(ui):
            # This represents an event handler that causes a nested UI to be
            # disposed.
            gui.invoke_later(editor.dispose_inner_ui)

            # Allowing GUI to process the disposal requests is crucial.
            # This requirement should be satisfied in production setting
            # where the dispose method is part of an event handler.
            # Not doing so before disposing the main UI would be a programming
            # error in tests settings.
            with reraise_exceptions():
                process_cascade_events()

            gui.invoke_later(close_control, ui.control)
            with reraise_exceptions():
                process_cascade_events()

            self.assertIsNone(ui.control)
Beispiel #2
0
        def init(self, parent):
            self.control = TraitsUIPanel(parent, -1)

            sizer = wx.BoxSizer(wx.HORIZONTAL)
            self._dummy = DummyObject()
            self._ui = self._dummy.edit_traits(
                parent=self.control,
                kind="subpanel",
                view=View(
                    Item(
                        "number",
                        editor=BasicEditorFactory(klass=DummyButtonEditor),
                    ), ),
            )
            sizer.Add(self._ui.control, 1, wx.EXPAND)
            self.control.SetSizerAndFit(sizer)
Beispiel #3
0
 def test_close_ui(self):
     # Test closing the main window normally.
     obj = DummyObject()
     view = View(
         Group(
             Item(
                 "number",
                 editor=BasicEditorFactory(klass=EditorWithCustomWidget),
             ), ), )
     ui = obj.edit_traits(view=view)
     with ensure_destroyed(ui):
         gui = GUI()
         gui.invoke_later(close_control, ui.control)
         with reraise_exceptions():
             process_cascade_events()
         self.assertIsNone(ui.control)
Beispiel #4
0
# (C) Copyright 2004-2021 Enthought, Inc., Austin, TX
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in LICENSE.txt and may be redistributed only under
# the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!

""" Defines a completely empty editor, intended to be used as a spacer.
"""

from traitsui.basic_editor_factory import BasicEditorFactory
from traitsui.toolkit import toolkit_object

# Callable which returns the editor to use in the ui.


def null_editor(*args, **traits):
    return toolkit_object("null_editor:NullEditor")(*args, **traits)


# -------------------------------------------------------------------------
#  Create the editor factory object:
# -------------------------------------------------------------------------
NullEditor = BasicEditorFactory(klass=null_editor)
# (C) Copyright 2004-2022 Enthought, Inc., Austin, TX
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in LICENSE.txt and may be redistributed only under
# the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!
""" Defines the key binding editor for use with the KeyBinding class. This is a
specialized editor used to associate a particular key with a control (i.e., the
key binding editor).
"""

from traitsui.basic_editor_factory import BasicEditorFactory
from traitsui.toolkit import toolkit_object

# Callable which returns the editor to use in the ui.


def key_binding_editor(*args, **traits):
    return toolkit_object("key_binding_editor:KeyBindingEditor")(*args,
                                                                 **traits)


# -------------------------------------------------------------------------
#  Create the editor factory object:
# -------------------------------------------------------------------------
KeyBindingEditor = ToolkitEditorFactory = BasicEditorFactory(
    klass=key_binding_editor)