def test_active_tabwidget_after_editor_containing_tabs_gets_focus(self):
        # Regression test: if an editor contains tabs, a change in focus
        # sets the editor area pane `active_tabwidget` to one of those tabs,
        # rather than the editor's tab, after certain operations (e.g.,
        # navigating the editor tabs using keyboard shortcuts).

        window = TaskWindow()

        task = SplitEditorAreaPaneTestTask()
        editor_area = task.editor_area
        window.add_task(task)

        # Show the window.
        with event_loop():
            window.open()

        with event_loop():
            app = get_app_qt4()
            app.setActiveWindow(window.control)

        # Add and activate an editor which contains tabs.
        editor = ViewWithTabsEditor()
        with event_loop():
            editor_area.add_editor(editor)
        with event_loop():
            editor_area.activate_editor(editor)

        # Check that the active tabwidget is the right one.
        self.assertIs(editor_area.active_tabwidget,
                      editor_area.control.tabwidget())

        with event_loop():
            window.close()
Beispiel #2
0
    def set_common_menu_29(self):
        menubar = SMenuBar(
            SMenu(Separator(id="NewGroup", separator=False),
                  Separator(id="NewGroupEnd", separator=False),
                  Group(OpenAction(), id="OpenGroup"),
                  Separator(id="OpenGroupEnd", separator=False),
                  Separator(id="SaveGroupEnd", separator=False),
                  Group(ExitAction(), id="ExitGroup"),
                  id='File',
                  name='&File'),
            SMenu(PreferencesAction(), id='Edit', name='&Edit'),
            SMenu(AboutAction(), id='Help', name='&Help'),
        )
        app = wx.GetApp()
        # Create a fake task so we can use the menu creation routines
        window = TaskWindow(application=self.application)
        log.debug("OSXMenuBarPlugin: minimal menu extra items: %s" %
                  str(self.minimal_menu_actions))
        task = OSXMinimalTask(menu_bar=menubar,
                              window=window,
                              extra_actions=self.minimal_menu_actions)

        t = TaskActionManagerBuilder(task=task)
        mgr = t.create_menu_bar_manager()
        control = mgr.create_menu_bar(app)
        wx.MenuBar.MacSetCommonMenuBar(control)

        # Prevent wx from exiting when the last window is closed
        app.SetExitOnFrameDelete(False)
    def test_no_context_menu_if_outside_tabwidgets(self):
        # Check that the case of a position not in any of the tab widgets
        # is handled correctly.
        window = TaskWindow()

        task = SplitEditorAreaPaneTestTask()
        window.add_task(task)

        with event_loop():
            window.open()

        editor_area = task.editor_area
        editor_area_widget = editor_area.control
        tab_widget, = editor_area_widget.tabwidgets()

        # Position is relative to the receiving widget, so (-1, -1) should be
        # reliably outside.
        pos = QtCore.QPoint(-1, -1)
        context_menu_event = QtGui.QContextMenuEvent(
            QtGui.QContextMenuEvent.Mouse,
            pos,
        )

        global_pos = editor_area_widget.mapToGlobal(pos)
        self.assertIsNone(editor_area.get_context_menu(global_pos))

        # Exercise the context menu code to make sure it doesn't raise. (It
        # should do nothing.)
        with event_loop():
            tab_widget.contextMenuEvent(context_menu_event)

        with event_loop():
            window.close()
Beispiel #4
0
def main(argv):
    """ A simple example of using Tasks.
    """
    # Create the GUI (this does NOT start the GUI event loop).
    gui = GUI()

    # Create a Task and add it to a TaskWindow.
    task1 = ExampleTask()
    window = TaskWindow(size=(800, 600))
    window.add_task(task1)
    window.open()

    task2 = SecondTask()
    window = TaskWindow(size=(800, 600))
    window.add_task(task2)
    window.open()

    # Start the GUI event loop.
    gui.start_event_loop()
def main(argv):
    """ A simple example of using Tasks.
    """
    # Create the GUI (this does NOT start the GUI event loop).
    gui = GUI()

    # Create a Task and add it to a TaskWindow.
    task = ImageViewerTask()
    window = TaskWindow(size=(800, 600))
    window.add_task(task)
    # Show the window.
    window.open()

    # Start the GUI event loop.
    gui.start_event_loop()
    def setUp(self):
        # Set up the bogus task with its window.
        self.task = BogusTask()

        window = TaskWindow()
        window.add_task(self.task)

        self.task_state = window._get_state(self.task)

        # Fish the dock pane toggle group from the menu bar manager.
        dock_pane_toggle_group = []
        def find_doc_pane_toggle(item):
            if item.id == 'tests.bogus_task.DockPaneToggleGroup':
                dock_pane_toggle_group.append(item)

        self.task_state.menu_bar_manager.walk(find_doc_pane_toggle)

        self.dock_pane_toggle_group = dock_pane_toggle_group[0]
Beispiel #7
0
def main():
    """ A program for visualizing Sim4Life EM fields from scES simulations
    """
    configuration = ConfigParser()
    configuration.read_file(open('src/default.ini'))
    configuration.read(['config.ini'])
    push_exception_handler(reraise_exceptions=True)
    # Create the GUI (this does NOT start the GUI event loop).
    gui = GUI()

    # Create a Task and add it to a TaskWindow.
    task = S4LVisualizationTask(configuration=configuration)
    window = TaskWindow(
        size=(configuration.getint('Display', 'window_width'),
              configuration.getint('Display', 'window_height')))
    window.add_task(task)

    # Show the window.
    window.open()

    # Start the GUI event loop.
    gui.start_event_loop()
def main(argv):
    """ A simple example of using Tasks.
    """
    # Create the GUI (this does NOT start the GUI event loop).
    from traits.etsconfig.api import ETSConfig
    ETSConfig.toolkit = 'qt4'

    from enaml.qt.qt_application import QtApplication
    app = QtApplication()

    gui = GUI()

    # Create a Task and add it to a TaskWindow.
    task = EnamlTask()
    window = TaskWindow(size=(800, 600))
    window.add_task(task)

    # Show the window.
    window.open()

    # Start the GUI event loop.
    gui.start_event_loop()
    def test_editor_tooltip_change_inactive(self):
        # regression test related to pyface#523
        window = TaskWindow(size=(800, 600))

        task = SplitEditorAreaPaneTestTask()
        editor_area = task.editor_area
        window.add_task(task)

        # Show the window.
        with event_loop():
            window.open()

        with event_loop():
            app = get_app_qt4()
            app.setActiveWindow(window.control)

        # Add and activate an editor which contains tabs.
        left_editor = ViewWithTabsEditor()
        right_editor = ViewWithTabsEditor()

        with event_loop():
            editor_area.add_editor(left_editor)
        with event_loop():
            editor_area.control.split(orientation=QtCore.Qt.Orientation.Horizontal)
        with event_loop():
            editor_area.add_editor(right_editor)

        editor_area.activate_editor(right_editor)

        # change the name of the inactive editor
        left_editor.tooltip = "New Tooltip"

        # the text of the editor's tab should have changed
        left_tabwidget = editor_area.tabwidgets()[0]
        index = left_tabwidget.indexOf(left_editor.control)
        tab_tooltip = left_tabwidget.tabToolTip(index)

        self.assertEqual(tab_tooltip, "New Tooltip")
    def test_active_editor_after_focus_change(self):
        window = TaskWindow(size=(800, 600))

        task = SplitEditorAreaPaneTestTask()
        editor_area = task.editor_area
        window.add_task(task)

        # Show the window.
        with event_loop():
            window.open()

        with event_loop():
            app = get_app_qt4()
            app.setActiveWindow(window.control)

        # Add and activate an editor which contains tabs.
        left_editor = ViewWithTabsEditor()
        right_editor = ViewWithTabsEditor()

        with event_loop():
            editor_area.add_editor(left_editor)
        with event_loop():
            editor_area.control.split(orientation=QtCore.Qt.Horizontal)
        with event_loop():
            editor_area.add_editor(right_editor)

        editor_area.activate_editor(right_editor)
        self.assertEqual(editor_area.active_editor, right_editor)

        with event_loop():
            left_editor.control.setFocus()

        self.assertIsNotNone(editor_area.active_editor)
        self.assertEqual(editor_area.active_editor, left_editor)

        with event_loop():
            window.close()
    def test_context_menu_merge_text_top_bottom_split(self):
        # Regression test for enthought/pyface#422
        window = TaskWindow()

        task = SplitEditorAreaPaneTestTask()
        editor_area = task.editor_area
        window.add_task(task)

        with event_loop():
            window.open()

        editor_area_widget = editor_area.control
        with event_loop():
            editor_area_widget.split(orientation=QtCore.Qt.Vertical)

        # Get the tabs.
        top_tab, bottom_tab = editor_area_widget.tabwidgets()

        # Check top context menu merge text.
        top_tab_center = top_tab.mapToGlobal(top_tab.rect().center())
        top_context_menu = editor_area.get_context_menu(top_tab_center)
        self.assertEqual(
            top_context_menu.find_item("merge").action.name,
            "Merge with bottom pane",
        )

        # And the bottom context menu merge text.
        bottom_tab_center = bottom_tab.mapToGlobal(bottom_tab.rect().center())
        bottom_context_menu = editor_area.get_context_menu(bottom_tab_center)
        self.assertEqual(
            bottom_context_menu.find_item("merge").action.name,
            "Merge with top pane",
        )

        with event_loop():
            window.close()
    def test_context_menu_merge_text_left_right_split(self):
        # Regression test for enthought/pyface#422
        window = TaskWindow()

        task = SplitEditorAreaPaneTestTask()
        editor_area = task.editor_area
        window.add_task(task)

        with event_loop():
            window.open()

        editor_area_widget = editor_area.control
        with event_loop():
            editor_area_widget.split(orientation=QtCore.Qt.Horizontal)

        # Get the tabs.
        left_tab, right_tab = editor_area_widget.tabwidgets()

        # Check left context menu merge text.
        left_tab_center = left_tab.mapToGlobal(left_tab.rect().center())
        left_context_menu = editor_area.get_context_menu(left_tab_center)
        self.assertEqual(
            left_context_menu.find_item("merge").action.name,
            "Merge with right pane",
        )

        # And the right context menu merge text.
        right_tab_center = right_tab.mapToGlobal(right_tab.rect().center())
        right_context_menu = editor_area.get_context_menu(right_tab_center)
        self.assertEqual(
            right_context_menu.find_item("merge").action.name,
            "Merge with left pane",
        )

        with event_loop():
            window.close()
Beispiel #13
0
        return TaskLayout(
            top=PaneItem('example_pane_1'),
            right=PaneItem('example_pane_2'),
            bottom=PaneItem('example_pane_3'),
            left=PaneItem('example_pane_4'),
        )

    def activated(self):
        self.window.title = 'Dock Example Task'

    def create_central_pane(self):
        return PythonEditorPane(id='example_editor_pane', name='Python Editor')

    def create_dock_panes(self):
        pane1 = ExamplePane(id='example_pane_1', name='Example Pane 1')
        pane2 = ExamplePane(id='example_pane_2', name='Example Pane 2')
        pane3 = ExamplePane(id='example_pane_3', name='Example Pane 3')
        pane4 = ExamplePane(id='example_pane_4', name='Example Pane 4')
        return [pane1, pane2, pane3, pane4]

if __name__ == '__main__':

    gui = GUI()

    task = ExampleTask()
    window = TaskWindow()
    window.add_task(task)
    window.open()

    gui.start_event_loop()
Beispiel #14
0
 def _task_window_default(self):
     from pyface.tasks.api import TaskWindow
     window = TaskWindow(size=(960, 720))
     return window
Beispiel #15
0
from pyface.api import GUI
from pyface.tasks.api import TaskWindow, Task, TraitsTaskPane
from traitsui.api import Label, View


class MyCentralPane(TraitsTaskPane):
    id = "mypane"
    name = "My Pane"

    view = View(Label("Central Pane"))


class MyTask(Task):
    id = "mytask"
    name = "My Task"

    def create_central_pane(self):
        return MyCentralPane()


if __name__ == '__main__':
    gui = GUI()
    window = TaskWindow(size=(400, 300))
    window.add_task(MyTask())
    window.open()
    gui.start_event_loop()