Exemplo n.º 1
0
    def __init__(self, *args, show_tooltip=False, **kws):
        super().__init__(*args, **kws)
        self._filled_with_arch_data = dict()
        self._show_tooltip = show_tooltip

        self.vb2 = ViewBox()
        self.plotItem.scene().addItem(self.vb2)
        self.vb2.setXLink(self.plotItem)
        self.plotItem.getAxis('right').linkToView(self.vb2)
        self._updateViews()
        self.plotItem.vb.sigResized.connect(self._updateViews)

        self.carch = None

        # show auto adjust button
        self.plotItem.showButtons()

        # use pan mouse mode (3-button)
        self.plotItem.getViewBox().setMouseMode(ViewBox.PanMode)

        # connect sigMouseMoved
        self.plotItem.scene().sigMouseMoved.connect(self._handle_mouse_moved)

        # add new actions to menu
        rst_act = QAction("Clear buffers")
        rst_act.triggered.connect(self._resetBuffers)
        tsp_act = QAction("Change time span")
        tsp_act.triggered.connect(self._changeTimeSpan)
        self.plotItem.scene().contextMenu.extend([rst_act, tsp_act])
Exemplo n.º 2
0
    def InitMenu(self):
        mainMenu = self.menuBar
        fileMenu = mainMenu.addMenu('File')

        SaveRec1Action = QAction('Save Rec1 as', self)
        SaveRec1Action.setStatusTip('Save a copy of Rec1 and Evens')
        SaveRec1Action.triggered.connect(self.SaveRec1)
        fileMenu.addAction(SaveRec1Action)

        SaveJoinRecAction = QAction('Join Rec1 and Rec2 as', self)
        SaveJoinRecAction.setStatusTip(
            'Save a copy of Rec1 and Rec2 with Tstart')
        SaveJoinRecAction.triggered.connect(self.SaveJoinRec)
        fileMenu.addAction(SaveJoinRecAction)

        SaveFigAction = QAction('Save Figures', self)
        SaveFigAction.setShortcut('Ctrl+s')
        SaveFigAction.setStatusTip('Save all open figures')
        SaveFigAction.triggered.connect(self.SaveFigures)
        fileMenu.addAction(SaveFigAction)

        CloseFigsAction = QAction('Close Figures', self)
        CloseFigsAction.setStatusTip('Close all open figures')
        CloseFigsAction.triggered.connect(self.CloseFigures)
        fileMenu.addAction(CloseFigsAction)
Exemplo n.º 3
0
Arquivo: view.py Projeto: dpaj/mantid
    def set_context_menu_actions(self, table):
        """
        Sets up the context menu actions for the table
        :type table: QTableView
        :param table: The table whose context menu actions will be set up.
        :param ws_read_function: The read function used to efficiently retrieve data directly from the workspace
        """
        copy_action = QAction(self.COPY_ICON, "Copy", table)
        copy_action.triggered.connect(self.presenter.action_copy_cells)

        table.setContextMenuPolicy(Qt.ActionsContextMenu)
        table.addAction(copy_action)

        horizontalHeader = table.horizontalHeader()
        horizontalHeader.setContextMenuPolicy(Qt.CustomContextMenu)
        horizontalHeader.customContextMenuRequested.connect(self.custom_context_menu)

        verticalHeader = table.verticalHeader()
        verticalHeader.setContextMenuPolicy(Qt.ActionsContextMenu)
        verticalHeader.setSectionResizeMode(QHeaderView.Fixed)

        copy_spectrum_values = QAction(self.COPY_ICON, "Copy", verticalHeader)
        copy_spectrum_values.triggered.connect(self.presenter.action_copy_spectrum_values)

        delete_row = QAction(self.DELETE_ROW, "Delete Row", verticalHeader)
        delete_row.triggered.connect(self.presenter.action_delete_row)

        separator2 = self.make_separator(verticalHeader)

        verticalHeader.addAction(copy_spectrum_values)
        verticalHeader.addAction(separator2)
        verticalHeader.addAction(delete_row)
Exemplo n.º 4
0
 def _create_actions(self):
     self.blctrl_enbl_act = QAction("Enable Beamline Control", self)
     self.blctrl_enbl_act.triggered.connect(
         lambda: self._set_beamline_control(True))
     self.blctrl_dsbl_act = QAction("Disable Beamline Control", self)
     self.blctrl_dsbl_act.triggered.connect(
         lambda: self._set_beamline_control(False))
Exemplo n.º 5
0
    def __init__(self, parent):
        """

        :param parent:
        :return:
        """
        base.CustomizedTreeView.__init__(self, parent)

        # define actions
        self._action_plot = QAction('Plot', self)
        self._action_plot.triggered.connect(self.do_plot)

        # to python
        self._action_ipython = QAction('To IPython', self)
        self._action_ipython.triggered.connect(self.do_copy_to_ipython)

        # remove from plot
        self._action_remove_plot = QAction('Remove from plot', self)
        self._action_remove_plot.triggered.connect(self.do_remove_from_plot)

        # delete workspace/data
        self._action_delete = QAction('Delete data', self)
        self._action_delete.triggered.connect(self.do_delete_selected_items)

        self._mainWindow = None
        self._workspaceNameList = None

        self.reset_gr_tree()

        return
Exemplo n.º 6
0
    def _setup_actions(self):
        """Creates the main window actions."""
        # Show/hide callable objects
        self.toggle_show_callable_action = QAction(
            _("Show callable attributes"),
            self,
            checkable=True,
            shortcut=QKeySequence("Alt+C"),
            statusTip=_("Shows/hides attributes that are callable "
                        "(functions, methods, etc)"))
        self.toggle_show_callable_action.toggled.connect(
            self._proxy_tree_model.setShowCallables)
        self.toggle_show_callable_action.toggled.connect(
            self.obj_tree.resize_columns_to_contents)

        # Show/hide special attributes
        self.toggle_show_special_attribute_action = QAction(
            _("Show __special__ attributes"),
            self,
            checkable=True,
            shortcut=QKeySequence("Alt+S"),
            statusTip=_("Shows or hides __special__ attributes"))
        self.toggle_show_special_attribute_action.toggled.connect(
            self._proxy_tree_model.setShowSpecialAttributes)
        self.toggle_show_special_attribute_action.toggled.connect(
            self.obj_tree.resize_columns_to_contents)
Exemplo n.º 7
0
    def setup_menu(self):
        menubar = self.menuBar()

        file_menu = menubar.addMenu('&Archivo')

        refresh_action = QAction(qta.icon('fa5s.sync'), '&Actualizar', self)
        refresh_action.setShortcut('Ctrl+A')
        refresh_action.setStatusTip(
            'Actualizando Base de Datos de Artículos....')
        refresh_action.triggered.connect(
            scraper.scrapeAll)  # Llamar al método de scrapper
        file_menu.addAction(refresh_action)

        exit_action = QAction(qta.icon('fa5.times-circle'), '&Salir', self)
        exit_action.setShortcut('Ctrl+Q')
        exit_action.setStatusTip('Saliendo de la aplicación....')
        exit_action.triggered.connect(QApplication.instance().closeAllWindows)
        file_menu.addAction(exit_action)

        help_menu = menubar.addMenu('&Ayuda')
        about_action = QAction(qta.icon('fa5s.info-circle'), '&Acerca de',
                               self)
        about_action.setShortcut('Ctrl+I')
        about_action.setStatusTip('Acerca de...')
        about_action.triggered.connect(self.show_about_dialog)
        help_menu.addAction(about_action)
Exemplo n.º 8
0
 def setup_plot_spectrum_actions(self, context_menu, table):
     plot_spectrum_action = QAction(self.GRAPH_ICON,
                                    "Plot spectrum (values only)", self)
     plot_spectrum_action.triggered.connect(
         partial(self.presenter.action_plot_spectrum, table))
     plot_spectrum_with_errors_action = QAction(
         self.GRAPH_ICON, "Plot spectrum (values + errors)", self)
     plot_spectrum_with_errors_action.triggered.connect(
         partial(self.presenter.action_plot_spectrum_with_errors, table))
     overplot_spectrum_action = QAction(self.GRAPH_ICON,
                                        "Overplot spectrum (values only)",
                                        self)
     overplot_spectrum_action.triggered.connect(
         partial(self.presenter.action_overplot_spectrum, table))
     overplot_spectrum_with_errors_action = QAction(
         self.GRAPH_ICON, "Overplot spectrum (values + errors)", self)
     overplot_spectrum_with_errors_action.triggered.connect(
         partial(self.presenter.action_overplot_spectrum_with_errors,
                 table))
     overplot_spectrum_action.setEnabled(can_overplot())
     overplot_spectrum_with_errors_action.setEnabled(can_overplot())
     separator = QAction(self)
     separator.setSeparator(True)
     list(
         map(context_menu.addAction, [
             plot_spectrum_action, plot_spectrum_with_errors_action,
             separator, overplot_spectrum_action,
             overplot_spectrum_with_errors_action
         ]))
Exemplo n.º 9
0
    def _add_plugins_menu(self):
        """Add 'Plugins' menu to app menubar."""
        self.plugins_menu = self.main_menu.addMenu('&Plugins')

        list_plugins_action = QAction("List Installed Plugins...",
                                      self._qt_window)
        list_plugins_action.setStatusTip('List installed plugins')
        list_plugins_action.triggered.connect(self._show_plugin_list)
        self.plugins_menu.addAction(list_plugins_action)

        pip_install_action = QAction("Install/Uninstall Package(s)...",
                                     self._qt_window)
        pip_install_action.triggered.connect(self._show_pip_install_dialog)
        self.plugins_menu.addAction(pip_install_action)

        order_plugin_action = QAction("Plugin Call Order...", self._qt_window)
        order_plugin_action.setStatusTip('Change call order for plugins')
        order_plugin_action.triggered.connect(self._show_plugin_sorter)
        self.plugins_menu.addAction(order_plugin_action)

        report_plugin_action = QAction("Plugin Errors...", self._qt_window)
        report_plugin_action.setStatusTip(
            'Review stack traces for plugin exceptions and notify developers')
        report_plugin_action.triggered.connect(self._show_plugin_err_reporter)
        self.plugins_menu.addAction(report_plugin_action)
Exemplo n.º 10
0
    def _add_file_menu(self):
        """Add 'File' menu to app menubar."""
        open_images = QAction('Open image(s)...', self._qt_window)
        open_images.setShortcut('Ctrl+O')
        open_images.setStatusTip('Open image file(s)')
        open_images.triggered.connect(self.qt_viewer._open_images)

        open_stack = QAction('Open image series as stack...', self._qt_window)
        open_stack.setShortcut('Ctrl+Alt+O')
        open_stack.setStatusTip('Open image files')
        open_stack.triggered.connect(self.qt_viewer._open_images_as_stack)

        open_folder = QAction('Open Folder...', self._qt_window)
        open_folder.setShortcut('Ctrl+Shift+O')
        open_folder.setStatusTip(
            'Open a folder of image file(s) or a zarr file')
        open_folder.triggered.connect(self.qt_viewer._open_folder)

        screenshot = QAction('Screenshot', self._qt_window)
        screenshot.setShortcut('Ctrl+Alt+S')
        screenshot.setStatusTip(
            'Save screenshot of current display, default .png')
        screenshot.triggered.connect(self.qt_viewer._save_screenshot)

        self.file_menu = self.main_menu.addMenu('&File')
        self.file_menu.addAction(open_images)
        self.file_menu.addAction(open_stack)
        self.file_menu.addAction(open_folder)
        self.file_menu.addAction(screenshot)
Exemplo n.º 11
0
    def _setup_menu(self):
        file_menu = self.menuBar().addMenu('File')

        new_action = QAction('New Notebook', self)
        new_action.triggered.connect(self.tabwidget.create_new_client)
        file_menu.addAction(new_action)

        open_action = QAction('Open Notebook...', self)
        open_action.triggered.connect(self.tabwidget.open_notebook)
        file_menu.addAction(open_action)

        save_action = QAction('Save Notebook', self)
        save_action.triggered.connect(
            lambda checked: self.tabwidget.save_notebook(self.tabwidget.
                                                         currentWidget()))
        file_menu.addAction(save_action)

        saveas_action = QAction('Save As...', self)
        saveas_action.triggered.connect(self.tabwidget.save_as)
        file_menu.addAction(saveas_action)

        close_action = QAction('Close Notebook', self)
        close_action.triggered.connect(
            lambda checked: self.tabwidget.close_client(self.tabwidget.
                                                        currentIndex()))
        file_menu.addAction(close_action)
Exemplo n.º 12
0
    def __init__(self, parent=None, show=True, off_screen=True):
        MainWindow.__init__(self, parent)

        self.frame = QFrame()
        vlayout = QVBoxLayout()
        self.vtk_widget = QtInteractor(
            parent=self.frame,
            off_screen=off_screen,
            stereo=False,
        )
        vlayout.addWidget(self.vtk_widget.interactor)

        self.frame.setLayout(vlayout)
        self.setCentralWidget(self.frame)

        mainMenu = _create_menu_bar(parent=self)

        fileMenu = mainMenu.addMenu('File')
        self.exit_action = QAction('Exit', self)
        self.exit_action.setShortcut('Ctrl+Q')
        self.exit_action.triggered.connect(self.close)
        fileMenu.addAction(self.exit_action)

        meshMenu = mainMenu.addMenu('Mesh')
        self.add_sphere_action = QAction('Add Sphere', self)
        self.exit_action.setShortcut('Ctrl+A')
        self.add_sphere_action.triggered.connect(self.add_sphere)
        meshMenu.addAction(self.add_sphere_action)

        self.signal_close.connect(self.vtk_widget.close)

        if show:
            self.show()
Exemplo n.º 13
0
    def setScene(self, scene: FlowScene):
        """
        setScene

        Parameters
        ----------
        scene : FlowScene
        """
        self._scene = scene
        super().setScene(self._scene)

        # setup actions
        del self._clear_selection_action
        self._clear_selection_action = QAction("Clear Selection", self)
        self._clear_selection_action.setShortcut(QKeySequence.Cancel)
        self._clear_selection_action.triggered.connect(
            self._scene.clearSelection)

        self.addAction(self._clear_selection_action)
        del self._delete_selection_action
        self._delete_selection_action = QAction("Delete Selection", self)
        self._delete_selection_action.setShortcut(QKeySequence.Backspace)
        self._delete_selection_action.setShortcut(QKeySequence.Delete)
        self._delete_selection_action.triggered.connect(self.delete_selected)
        self.addAction(self._delete_selection_action)
Exemplo n.º 14
0
    def __init__(self, tracker: Tracker) -> None:
        super().__init__()
        self.qttracker = QtTracker(tracker)
        self.bg_thread = QThread(self)
        self.qttracker.moveToThread(self.bg_thread)
        self.bg_thread.start()
        self.qttracker.start_recording()

        self.setCentralWidget(Controls(self.qttracker))
        toolbar = QToolBar()
        self.addToolBar(toolbar)
        toolbar.setMovable(False)
        toolbar.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.new_action = QAction("New", self)
        self.new_action.setToolTip("Create a new file for tracking.")
        icon = self.style().standardIcon(QStyle.SP_FileIcon)
        self.new_action.setIcon(icon)
        self.new_action.triggered.connect(self.new_db)
        toolbar.addAction(self.new_action)

        self.load_action = QAction("Load", self)
        self.load_action.setToolTip("Load a existing file for tracking.")
        icon = self.style().standardIcon(QStyle.SP_DialogOpenButton)
        self.load_action.setIcon(icon)
        self.load_action.triggered.connect(self.load_db)
        toolbar.addAction(self.load_action)
Exemplo n.º 15
0
    def _rebuild_samples_menu(self):
        from ...plugins import _npe2, menu_item_template, plugin_manager

        self.open_sample_menu.clear()

        for plugin_name, samples in chain(_npe2.sample_iterator(),
                                          plugin_manager._sample_data.items()):
            multiprovider = len(samples) > 1
            if multiprovider:
                menu = self.open_sample_menu.addMenu(plugin_name)
            else:
                menu = self.open_sample_menu

            for samp_name, samp_dict in samples.items():
                display_name = samp_dict['display_name'].replace("&", "&&")
                if multiprovider:
                    action = QAction(display_name, parent=self)
                else:
                    full_name = menu_item_template.format(
                        plugin_name, display_name)
                    action = QAction(full_name, parent=self)

                def _add_sample(*args, plg=plugin_name, smp=samp_name):
                    self._win._qt_viewer.viewer.open_sample(plg, smp)

                menu.addAction(action)
                action.triggered.connect(_add_sample)
Exemplo n.º 16
0
    def _set_actions_and_menus(self, nsb):
        """
        Set actions and menus created here and used by the namespace
        browser editor.

        Although this is not ideal, it's necessary to be able to use
        the CollectionsEditor widget separately from this plugin.
        """
        editor = nsb.editor

        # Actions
        editor.paste_action = self.paste_action
        editor.copy_action = self.copy_action
        editor.edit_action = self.edit_action
        editor.plot_action = self.plot_action
        editor.hist_action = self.hist_action
        editor.imshow_action = self.imshow_action
        editor.save_array_action = self.save_array_action
        editor.insert_action = self.insert_action
        editor.remove_action = self.remove_action
        editor.minmax_action = self.show_minmax_action
        editor.rename_action = self.rename_action
        editor.duplicate_action = self.duplicate_action
        editor.view_action = self.view_action

        # Menus
        editor.menu = self.context_menu
        editor.empty_ws_menu = self.empty_context_menu

        # These actions are not used for dictionaries (so we don't need them
        # for namespaces) but we have to create them so they can be used in
        # several places in CollectionsEditor.
        editor.insert_action_above = QAction()
        editor.insert_action_below = QAction()
Exemplo n.º 17
0
    def __init__(self, env):
        super().__init__()

        self._env = env
        self._extra_menu_actions = []
        self._extra_toolbar_actions = []

        self.update_title()

        main_menu = self.menuBar()
        self.main_menu = main_menu
        project_menu = main_menu.addMenu("&Project")

        toolbar = self.addToolBar("Top")
        self.toolbar = toolbar

        new_action = QAction("&New", self)
        new_action.setShortcut("Ctrl+N")
        new_action.setStatusTip("Create a new empty project")
        new_action.triggered.connect(lambda: env.new())
        project_menu.addAction(new_action)

        open_action = QAction("&Open...", self)
        open_action.setShortcut("Ctrl+O")
        open_action.setStatusTip("Open an existing project")
        open_action.triggered.connect(lambda: env.open())
        project_menu.addAction(open_action)

        save_action = QAction("&Save", self)
        self.save_action = save_action
        save_action.setShortcut("Ctrl+S")
        save_action.setIcon(QIcon.fromTheme("document-save"))
        #save_action.setIcon(self.style().standardIcon(
        #    self.style().SP_DialogSaveButton))
        save_action.setStatusTip("Save project")
        save_action.setEnabled(False)
        save_action.triggered.connect(lambda: env.save())
        project_menu.addAction(save_action)
        toolbar.addAction(save_action)

        save_as_action = QAction("Save &As...", self)
        save_as_action.setStatusTip("Save project under a new name")
        save_as_action.triggered.connect(lambda: env.save_as())
        project_menu.addAction(save_as_action)

        quit_action = QAction("&Quit", self)
        quit_action.setShortcut("Ctrl+Q")
        quit_action.setStatusTip("Quit Hildegard")
        quit_action.triggered.connect(self.handle_quit)
        project_menu.addAction(quit_action)

        self.tabs = QTabWidget()
        self.tabs.setTabsClosable(True)
        self.tabs.tabCloseRequested.connect(
            lambda index: env.close(self.tabs.widget(index).entity, quit=True))
        self.tabs.currentChanged.connect(self._handle_switch_to_tab)
        self.setCentralWidget(self.tabs)

        self.statusBar()
Exemplo n.º 18
0
    def _add_plugins_menu(self):
        """Add 'Plugins' menu to app menubar."""
        self.plugins_menu = self.main_menu.addMenu('&Plugins')

        pip_install_action = QAction("Install/Uninstall Package(s)...",
                                     self._qt_window)
        pip_install_action.triggered.connect(self._show_plugin_install_dialog)
        self.plugins_menu.addAction(pip_install_action)

        order_plugin_action = QAction("Plugin Call Order...", self._qt_window)
        order_plugin_action.setStatusTip('Change call order for plugins')
        order_plugin_action.triggered.connect(self._show_plugin_sorter)
        self.plugins_menu.addAction(order_plugin_action)

        report_plugin_action = QAction("Plugin Errors...", self._qt_window)
        report_plugin_action.setStatusTip(
            'Review stack traces for plugin exceptions and notify developers')
        report_plugin_action.triggered.connect(self._show_plugin_err_reporter)
        self.plugins_menu.addAction(report_plugin_action)

        self._plugin_dock_widget_menu = QMenu('Add Dock Widget',
                                              self._qt_window)

        # Get names of all plugins providing dock widgets or functions
        plugin_widgets = chain(plugins.dock_widgets, plugins.function_widgets)
        plugin_counts = Counter(plug_name for plug_name, _ in plugin_widgets)

        # Add submenu for each plugin with more than 1 item
        for plugin_name, count in plugin_counts.items():
            if count > 1:
                menu = QMenu(plugin_name, self._qt_window)
                self._plugin_menus[plugin_name] = menu
                self._plugin_dock_widget_menu.addMenu(menu)

        # Add a menu item (QAction) for each available plugin widget
        docks = zip(repeat("dock"), plugins.dock_widgets)
        funcs = zip(repeat("func"), plugins.function_widgets)
        for hook_type, key in chain(docks, funcs):
            plugin_name, wdg_name = key
            if plugin_name in self._plugin_menus:
                # this plugin has a submenu.
                action = QAction(wdg_name, parent=self._qt_window)
                self._plugin_menus[plugin_name].addAction(action)
            else:
                # this plugin only has one widget, add a namespaced menu item
                full_name = plugins.menu_item_template.format(*key)
                action = QAction(full_name, parent=self._qt_window)
                self._plugin_dock_widget_menu.addAction(action)

            def _add_widget(*args, key=key, hook_type=hook_type):
                if hook_type == 'dock':
                    self._add_plugin_dock_widget(key)
                else:
                    self._add_plugin_function_widget(key)

            action.triggered.connect(_add_widget)

        self.plugins_menu.addMenu(self._plugin_dock_widget_menu)
Exemplo n.º 19
0
    def customMenuRequested(self, position):
        """Builds a custom menu for items items"""
        index = self.indexAt(position)  # type: QModelIndex
        menu = QMenu(self)

        if index.isValid():

            if index.data(EnsembleModel.data_type_role
                          ) == WorkspaceDataType.Ensemble:

                # Allow renaming the ensemble via the context menu
                rename_action = QAction("Rename Collection", menu)
                rename_action.triggered.connect(self._rename_action)
                menu.addAction(rename_action)

                # Allow toggling the active ensemble via the context menu
                # * there can only be at most 1 active ensemble
                # * there are only 0 active ensembles when data has not yet been loaded ???
                # * opening data updates the active ensemble to that data
                is_active = index.data(EnsembleModel.active_role)
                active_text = "Active"
                toggle_active_action = QAction(active_text, menu)
                toggle_active_action.setCheckable(True)
                if is_active is True:
                    toggle_active_action.setChecked(True)
                else:
                    toggle_active_action.setChecked(False)
                    toggle_active_action.setText(f"Not {active_text}")

                # Make sure to update the model with the active / deactivated ensemble
                toggle_active_action.toggled.connect(self._set_active_action)
                # Don't allow deactivating the active ensemble if there is only one loaded
                if self.model().rowCount() == 1:
                    toggle_active_action.setEnabled(False)
                menu.addAction(toggle_active_action)

                menu.addSeparator()

            remove_text = "Remove "
            data_type_role = index.data(EnsembleModel.data_type_role)
            if data_type_role == WorkspaceDataType.Ensemble:
                remove_text += "Ensemble"
            elif data_type_role == WorkspaceDataType.Catalog:
                remove_text += "Catalog"
            elif data_type_role == WorkspaceDataType.Intent:
                remove_text += "Item"
            remove_action = QAction(remove_text, menu)
            remove_action.triggered.connect(self._remove_action)
            menu.addAction(remove_action)

        else:
            create_ensemble_action = QAction("Create New Collection", menu)
            create_ensemble_action.triggered.connect(
                self._create_ensemble_action)
            menu.addAction(create_ensemble_action)

        # Display menu wherever the user right-clicked
        menu.popup(self.viewport().mapToGlobal(position))
Exemplo n.º 20
0
    def __init__(self, parent=None):
        super(QTiffStackPlayer, self).__init__(parent)

        self.setWindowTitle('Tiff Stack Player')

        self.videoviewer = QTiffStackView()
        #self.videoviewer.setSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.MinimumExpanding)

        #backend model (conforming to MVC design pattern)

        self.model = QTiffStackModel()

        #as controller this class contains the video index
        self.index = 0
        self.counterconnected = False
        #Create new action

        openAction = QAction('&Open', self)
        openAction.setShortcut('Ctrl+O')
        openAction.setStatusTip('Open movie')
        openAction.triggered.connect(self.openFile)

        #Create exit action

        exitAction = QAction('&Exit', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(self.exitCall)

        #Create menu bar and add action
        #QMainWindow has a default Menu Bar attribute accessible by calling self.menuBar()
        menuBar = self.menuBar()
        fileMenu = menuBar.addMenu('&File')
        fileMenu.addAction(openAction)
        fileMenu.addAction(exitAction)

        #add an error label

        errorLabel = QLabel()
        #This function call below sets the policy determining how the error label may be shrunk and expanded by the parent window. Syntax is 'QWidget.setSizePolicy (self, QSizePolicy.Policy hor, QSizePolicy.Policy ver)'
        errorLabel.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)

        layout = QVBoxLayout()
        self.setCentralWidget(self.videoviewer)

        #connect the signals from the viewer to the slots on the controller.

        self.videoviewer.frametimer.timeout.connect(self.getFrame)
        self.videoviewer.frametimer.timeout.connect(self.updateCounter)

        self.videoviewer.slideBar.valueChanged.connect(self.sliderChanged)
        self.videoviewer.slideBar.valueChanged.connect(self.updateCounter)
        self.videoviewer.play.clicked.connect(self.whenButtonPressed)

        self.videoviewer.counter.valueChanged.connect(self.counterChanged)
        self.counterconnected = True

        self.show()
Exemplo n.º 21
0
 def _GM_Family_t(self, m, node):
     a = QAction('Select references to myself', self)
     a.triggered.connect(functools.partial(self._gm_family_1, node))
     m.addAction(a)
     a = QAction('Select all families', self)
     a.triggered.connect(functools.partial(self._gm_family_2, node))
     m.addAction(a)
     m.addSeparator()
     return True
Exemplo n.º 22
0
 def _create_actions(self):
     self._act_check_all = QAction("Check All", self)
     self._act_check_all.triggered.connect(self.check_all)
     self._act_uncheck_all = QAction("Uncheck All", self)
     self._act_uncheck_all.triggered.connect(self.uncheck_all)
     self._act_expand_all = QAction("Expand All", self)
     self._act_expand_all.triggered.connect(self.expand_all)
     self._act_collapse_all = QAction("Collapse All", self)
     self._act_collapse_all.triggered.connect(self.collapse_all)
Exemplo n.º 23
0
 def _createActions(self):
     self.openPISettingsAction = QAction(self)
     self.openPISettingsAction.setText("Open PI settings")
     self.openSweepSettingsAction = QAction(self)
     self.openSweepSettingsAction.setText("Open sweep settings")
     self.openRelockSettingsAction = QAction(self)
     self.openRelockSettingsAction.setText("Open relock settings")
     self.openIOSettingsAction = QAction(self)
     self.openIOSettingsAction.setText("Open IO settings")
Exemplo n.º 24
0
    def __init__(self, *args, **kwargs):
        super(MOSViewerToolbar, self).__init__(*args, **kwargs)
        self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        # Define the toolbar actions
        self.cycle_previous_action = QAction(
            QIcon(os.path.join(ICON_DIR, "Previous-96.png")), "Previous", self)
        self.cycle_next_action = QAction(
            QIcon(os.path.join(ICON_DIR, "Next-96.png")), "Next", self)

        # Include the dropdown widget
        self.source_select = QComboBox()

        # Add the items to the toolbar
        self.addAction(self.cycle_previous_action)
        self.addAction(self.cycle_next_action)
        self.addWidget(self.source_select)

        # Include a button to open spectrum in specviz
        self.open_specviz = QAction(
            QIcon(os.path.join(ICON_DIR, "External-96.png")),
            "Open in SpecViz", self)

        # Create a tool button to hold the lock axes menu object
        tool_button = QToolButton(self)
        tool_button.setText("Axes Settings")
        tool_button.setIcon(QIcon(os.path.join(ICON_DIR, "Settings-96.png")))
        tool_button.setPopupMode(QToolButton.MenuButtonPopup)
        tool_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        # Create a menu for the axes settings drop down
        self.settings_menu = QMenu(self)

        # Add lock x axis action
        self.lock_x_action = QAction("Lock spectral axis", self.settings_menu)
        self.lock_x_action.setCheckable(True)

        # Add lock y axis action
        self.lock_y_action = QAction("Lock vertical displacement axis",
                                     self.settings_menu)
        self.lock_y_action.setCheckable(True)

        # Add the actions to the menu
        self.settings_menu.addAction(self.lock_x_action)
        self.settings_menu.addAction(self.lock_y_action)

        # Set the menu object on the tool button
        tool_button.setMenu(self.settings_menu)

        # Create a widget action object to hold the tool button, this way the
        # toolbar behaves the way it's expected to
        tool_button_action = QWidgetAction(self)
        tool_button_action.setDefaultWidget(tool_button)

        self.addAction(tool_button_action)
        self.addSeparator()
        self.addAction(self.open_specviz)
Exemplo n.º 25
0
    def __init__(self, *args, menuBar, **kwargs):
        super().__init__(*args, **kwargs)
        self._run_to_tabs = collections.defaultdict(list)
        self._title_to_tab = {}
        self._tabs_from_streaming = []
        self._overplot = OverPlotState.individual_tab
        self._overplot_target = None
        self._live_enabled = False

        self._live_run_router = RunRouter([self.route_live_stream])

        self._containers = [TabbedViewingArea(self, menuBar=menuBar) for _ in range(2)]
        layout = QVBoxLayout()
        for container in self._containers:
            layout.addWidget(container)
        self.setLayout(layout)

        overplot_group = QActionGroup(self)
        self.off = QAction('&Off', self)
        self.off.setStatusTip('Drop streaming data.')
        self.individual_tab = QAction('&New Tab', self)
        self.individual_tab.setStatusTip('Open a new viewer tab for each Run.')
        self.latest_live = QAction('&Latest Live Tab', self)
        self.latest_live.setStatusTip('Attempt to overplot on the most recent live Run.')
        self.fixed = QAction('&Fixed Tab...', self)
        self.fixed.setStatusTip('Attempt to overplot on a specific tab.')
        self.fixed.setEnabled(False)
        overplot_group.addAction(self.off)
        overplot_group.addAction(self.individual_tab)
        overplot_group.addAction(self.latest_live)
        overplot_group.addAction(self.fixed)
        for action in overplot_group.actions():
            action.setCheckable(True)
        overplot_group.setExclusive(True)
        self.off.setChecked(True)

        overplot_menu = menuBar().addMenu('&Streaming')
        overplot_menu.addActions(overplot_group.actions())

        self.off.triggered.connect(self.disable_live)
        self.individual_tab.triggered.connect(partial(self.set_overplot_state, OverPlotState.individual_tab))
        self.latest_live.triggered.connect(partial(self.set_overplot_state, OverPlotState.latest_live))

        def set_overplot_target():
            item, ok = QInputDialog.getItem(
                self, "Select Tab", "Tab", tuple(self._title_to_tab), 0, False)
            if not ok:
                # Abort and fallback to Off. Would be better to fall back to
                # previous state (which could be latest_live) but it's not
                # clear how to know what that state was.
                self.off.setChecked(True)
                return
            self.set_overplot_state(OverPlotState.fixed)
            self._overplot_target = item

        self.fixed.triggered.connect(set_overplot_target)
Exemplo n.º 26
0
 def create_actions(self):
     # Actions
     self.actions = {
         'Connect': QAction("Connect", self),
         'Quit': QAction("Quit", self),
         'AddPlot': QAction("Add Plot", self)
     }
     self.actions['Connect'].triggered.connect(self.on_action_connect_triggered)
     self.actions['Quit'].triggered.connect(qApp.quit)
     self.actions['AddPlot'].triggered.connect(self.on_action_add_plot_triggered)
Exemplo n.º 27
0
    def __init__(self, parent, widthSpace=10):
        super().__init__()

        self.parent = parent

        self.widthSpace = widthSpace
        self.dateFmt = "%d %b %Y"

        self.headerLabels = [
            'Date', 'Time', 'Distance (km)', 'Avg. speed\n(km/h)', 'Calories',
            'Gear'
        ]
        self.setHeaderLabels(self.headerLabels)
        self.header().setStretchLastSection(False)
        # make header tall enough for two rows of text (avg speed has line break)
        font = self.header().font()
        metrics = QFontMetrics(font)
        height = metrics.height()
        self.header().setMinimumHeight(height * 2)
        # align header text centrally
        for idx in range(len(self.headerLabels)):
            self.headerItem().setTextAlignment(idx, Qt.AlignCenter)

        self.setSelectionMode(QAbstractItemView.ExtendedSelection)

        self.makeTree()

        self.sortColumn = None
        self.sortDescending = [True for _ in range(len(self.headerLabels))]
        self.header().setSectionsClickable(True)
        self.header().sectionClicked.connect(self.sortTree)

        self.currentItemChanged.connect(self._itemChanged)

        self.itemSelectionChanged.connect(self._summariseSelected)

        self.sortTree(0)

        msg = "Browse all sessions, grouped by month. Click on the headers \n"
        msg += "to sort by that metric in ascending or descending order.\n"
        msg += "Click on a session to highlight it in the plot."
        self.setToolTip(msg)

        self.editAction = QAction("Edit")
        self.editAction.setShortcut(QKeySequence("Ctrl+E"))
        self.editAction.triggered.connect(self._editItems)
        self.addAction(self.editAction)

        self.mergeAction = QAction("Merge")
        self.mergeAction.setShortcut(QKeySequence("Ctrl+M"))
        self.mergeAction.triggered.connect(self.combineRows)
        self.addAction(self.mergeAction)

        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._showContextMenu)
Exemplo n.º 28
0
    def _add_plugins_menu(self):
        """Add 'Plugins' menu to app menubar."""
        self.plugins_menu = self.main_menu.addMenu('&Plugins')

        pip_install_action = QAction("Install/Uninstall Package(s)...",
                                     self._qt_window)
        pip_install_action.triggered.connect(self._show_plugin_install_dialog)
        self.plugins_menu.addAction(pip_install_action)

        order_plugin_action = QAction("Plugin Call Order...", self._qt_window)
        order_plugin_action.setStatusTip('Change call order for plugins')
        order_plugin_action.triggered.connect(self._show_plugin_sorter)
        self.plugins_menu.addAction(order_plugin_action)

        report_plugin_action = QAction("Plugin Errors...", self._qt_window)
        report_plugin_action.setStatusTip(
            'Review stack traces for plugin exceptions and notify developers')
        report_plugin_action.triggered.connect(self._show_plugin_err_reporter)
        self.plugins_menu.addAction(report_plugin_action)

        self._plugin_dock_widget_menu = QMenu('Add Dock Widget',
                                              self._qt_window)

        if not plugins.dock_widgets:
            plugins.discover_dock_widgets()

        # Add a menu item (QAction) for each available plugin widget
        docks = zip(repeat("dock"), plugins.dock_widgets.items())
        funcs = zip(repeat("func"), plugins.function_widgets.items())
        for hook_type, (plugin_name, widgets) in chain(docks, funcs):
            multiprovider = len(widgets) > 1
            if multiprovider:
                menu = QMenu(plugin_name, self._qt_window)
                self._plugin_dock_widget_menu.addMenu(menu)
            else:
                menu = self._plugin_dock_widget_menu

            for wdg_name in widgets:
                key = (plugin_name, wdg_name)
                if multiprovider:
                    action = QAction(wdg_name, parent=self._qt_window)
                else:
                    full_name = plugins.menu_item_template.format(*key)
                    action = QAction(full_name, parent=self._qt_window)

                def _add_widget(*args, key=key, hook_type=hook_type):
                    if hook_type == 'dock':
                        self.add_plugin_dock_widget(*key)
                    else:
                        self._add_plugin_function_widget(*key)

                menu.addAction(action)
                action.triggered.connect(_add_widget)

        self.plugins_menu.addMenu(self._plugin_dock_widget_menu)
Exemplo n.º 29
0
 def _GM_IndexRange_t(self, m, node):
     if (node.sidsName() != CGK.ElementRange_s):
         v = 0
         a = QAction('Range size: %d' % (v), self)
         m.addAction(a)
     else:
         v = node.sidsValue()[1] - node.sidsValue()[0]
         etp = CGU.getEnumAsString(node.sidsParent())
         a = QAction('Number of elements of type [%s]: %d' % (etp, v), self)
         m.addAction(a)
     return True
Exemplo n.º 30
0
    def on_mouse_press_event(self, event):
        """
        Event handling for mouse press action
        Args:
            event:

        Returns:

        """
        # get the button and position information.
        curr_x = event.xdata
        curr_y = event.ydata
        if curr_x is None or curr_y is None:
            # outside of canvas
            return

        button = event.button
        if button == 1:
            # left button: no operation
            pass

        elif button == 3:
            # right button:
            # Pop-out menu
            self.menu = QMenu(self)

            if self.get_canvas().is_legend_on:
                # figure has legend: remove legend
                action1 = QAction('Hide legend', self)
                action1.triggered.connect(self._myCanvas.hide_legend)

                action2 = QAction('Legend font larger', self)
                action2.triggered.connect(
                    self._myCanvas.increase_legend_font_size)

                action3 = QAction('Legend font smaller', self)
                action3.triggered.connect(
                    self._myCanvas.decrease_legend_font_size)

                self.menu.addAction(action2)
                self.menu.addAction(action3)

            else:
                # figure does not have legend: add legend
                action1 = QAction('Show legend', self)
                action1.triggered.connect(self._myCanvas.show_legend)

            self.menu.addAction(action1)

            # pop up menu
            self.menu.popup(QCursor.pos())
        # END-IF-ELSE

        return