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()
    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()
    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()
Example #4
0
def main(argv):
    # Create the GUI (this does NOT start the GUI event loop).
    gui = GUI()

    # Create a Task and add it to a TaskWindow.
    task = ExampleTask()
    window = TaskWindow(size=(800, 600))
    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).
    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()
Example #6
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.
    task = BlankTask()
    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]
Example #8
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).
    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()
Example #10
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 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_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()
Example #16
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()
Example #17
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()