Exemplo n.º 1
0
    def __init__(self, parent, video: Video, index, first=False):
        self.loading = True
        super().__init__(parent)
        self.parent = parent
        self.index = index
        self.first = first
        self.last = False
        self.video = video.copy()
        self.setFixedHeight(60)

        self.widgets = Box(
            up_button=QtWidgets.QPushButton(QtGui.QIcon(up_arrow_icon), ""),
            down_button=QtWidgets.QPushButton(QtGui.QIcon(down_arrow_icon),
                                              ""),
            cancel_button=QtWidgets.QPushButton(QtGui.QIcon(black_x_icon), ""),
            reload_button=QtWidgets.QPushButton(QtGui.QIcon(edit_box_icon),
                                                ""),
            retry_button=QtWidgets.QPushButton(QtGui.QIcon(undo_icon), ""),
        )

        for widget in self.widgets.values():
            widget.setStyleSheet(no_border)

        title = QtWidgets.QLabel(
            video.video_settings.video_title if video.video_settings.
            video_title else video.video_settings.output_path.name)
        title.setFixedWidth(300)

        settings = Box(copy.deepcopy(video.video_settings.dict()))
        settings.output_path = str(settings.output_path)
        for i, o in enumerate(settings.attachment_tracks):
            if o.get("file_path"):
                o["file_path"] = str(o["file_path"])
        del settings.conversion_commands

        title.setToolTip(settings.to_yaml())

        open_button = QtWidgets.QPushButton(QtGui.QIcon(folder_icon),
                                            t("Open Directory"))
        open_button.setLayoutDirection(QtCore.Qt.RightToLeft)
        open_button.setIconSize(QtCore.QSize(14, 14))
        open_button.clicked.connect(
            lambda: open_folder(video.video_settings.output_path.parent))

        view_button = QtWidgets.QPushButton(QtGui.QIcon(play_icon), t("Watch"))
        view_button.setLayoutDirection(QtCore.Qt.RightToLeft)
        view_button.setIconSize(QtCore.QSize(14, 14))
        view_button.clicked.connect(lambda: QtGui.QDesktopServices.openUrl(
            QtCore.QUrl.fromLocalFile(str(video.video_settings.output_path))))

        open_button.setStyleSheet(no_border)
        view_button.setStyleSheet(no_border)

        add_retry = False
        status = t("Ready to encode")
        if video.status.error:
            status = t("Encoding errored")
        elif video.status.complete:
            status = f"{t('Encoding complete')}"
        elif video.status.running:
            status = (
                f"{t('Encoding command')} {video.status.current_command + 1} {t('of')} "
                f"{len(video.video_settings.conversion_commands)}")
        elif video.status.cancelled:
            status = t("Cancelled")
            add_retry = True

        if not self.video.status.running:
            self.widgets.cancel_button.clicked.connect(
                lambda: self.parent.remove_item(self.video))
            self.widgets.reload_button.clicked.connect(
                lambda: self.parent.reload_from_queue(self.video))
            self.widgets.cancel_button.setFixedWidth(25)
            self.widgets.reload_button.setFixedWidth(25)
        else:
            self.widgets.cancel_button.hide()
            self.widgets.reload_button.hide()

        grid = QtWidgets.QGridLayout()
        grid.addLayout(self.init_move_buttons(), 0, 0)
        # grid.addWidget(self.widgets.track_number, 0, 1)
        grid.addWidget(title, 0, 1, 1, 3)
        grid.addWidget(
            QtWidgets.QLabel(
                f"{video.video_settings.video_encoder_settings.name}"), 0, 4)
        grid.addWidget(
            QtWidgets.QLabel(
                f"{t('Audio Tracks')}: {len(video.video_settings.audio_tracks)}"
            ), 0, 5)
        grid.addWidget(
            QtWidgets.QLabel(
                f"{t('Subtitles')}: {len(video.video_settings.subtitle_tracks)}"
            ), 0, 6)
        grid.addWidget(QtWidgets.QLabel(status), 0, 7)
        if video.status.complete:
            grid.addWidget(view_button, 0, 8)
            grid.addWidget(open_button, 0, 9)
        elif add_retry:
            grid.addWidget(self.widgets.retry_button, 0, 8)
            self.widgets.retry_button.setFixedWidth(25)
            self.widgets.retry_button.clicked.connect(
                lambda: self.parent.retry_video(self.video))

        right_buttons = QtWidgets.QHBoxLayout()
        right_buttons.addWidget(self.widgets.reload_button)
        right_buttons.addWidget(self.widgets.cancel_button)

        grid.addLayout(right_buttons, 0, 10, alignment=QtCore.Qt.AlignRight)

        self.setLayout(grid)
        self.loading = False
        self.updating_burn = False
Exemplo n.º 2
0
import os
import sys
import multiprocessing as mp

mp.freeze_support()

os.environ['QT_API'] = 'pyside2'

from qtpy import QtWidgets
from app import GraniteApp

os.environ['QT_API'] = 'pyside2'

app = QtWidgets.QApplication(sys.argv)
app.setStyle('fusion')
ex = GraniteApp()
ex.show()
app.exec_()
Exemplo n.º 3
0
 def __init__(self, layout="vertical"):
     super().__init__(layout=layout)
     self._main_window = QtW.QMainWindow()
     self._main_window.setCentralWidget(self._qwidget)
     self._main_menu = self._main_window.menuBar()
     self._menus: dict[str, QtW.QMenu] = {}
Exemplo n.º 4
0
    def init_file_menu(self):
        self.file_menu = self.menuBar().addMenu("&File")

        self.new_kernel_tab_act = QtWidgets.QAction("New Tab with &New kernel",
            self,
            shortcut="Ctrl+T",
            triggered=self.create_tab_with_new_frontend)
        self.add_menu_action(self.file_menu, self.new_kernel_tab_act)

        self.slave_kernel_tab_act = QtWidgets.QAction("New Tab with Sa&me kernel",
            self,
            shortcut="Ctrl+Shift+T",
            triggered=self.create_tab_with_current_kernel)
        self.add_menu_action(self.file_menu, self.slave_kernel_tab_act)

        self.existing_kernel_tab_act = QtWidgets.QAction("New Tab with &Existing kernel",
                                                     self,
                                                     shortcut="Alt+T",
                                                     triggered=self.create_tab_with_existing_kernel)
        self.add_menu_action(self.file_menu, self.existing_kernel_tab_act)

        self.file_menu.addSeparator()

        self.close_action=QtWidgets.QAction("&Close Tab",
            self,
            shortcut=QtGui.QKeySequence.Close,
            triggered=self.close_active_frontend
            )
        self.add_menu_action(self.file_menu, self.close_action)

        self.export_action=QtWidgets.QAction("&Save to HTML/XHTML",
            self,
            shortcut=QtGui.QKeySequence.Save,
            triggered=self.export_action_active_frontend
            )
        self.add_menu_action(self.file_menu, self.export_action, True)

        self.file_menu.addSeparator()

        printkey = QtGui.QKeySequence(QtGui.QKeySequence.Print)
        if printkey.matches("Ctrl+P") and sys.platform != 'darwin':
            # Only override the default if there is a collision.
            # Qt ctrl = cmd on OSX, so the match gets a false positive on OSX.
            printkey = "Ctrl+Shift+P"
        self.print_action = QtWidgets.QAction("&Print",
            self,
            shortcut=printkey,
            triggered=self.print_action_active_frontend)
        self.add_menu_action(self.file_menu, self.print_action, True)

        if sys.platform != 'darwin':
            # OSX always has Quit in the Application menu, only add it
            # to the File menu elsewhere.

            self.file_menu.addSeparator()

            self.quit_action = QtWidgets.QAction("&Quit",
                self,
                shortcut=QtGui.QKeySequence.Quit,
                triggered=self.close,
            )
            self.add_menu_action(self.file_menu, self.quit_action)
Exemplo n.º 5
0
    def init_view_menu(self):
        self.view_menu = self.menuBar().addMenu("&View")

        if sys.platform != 'darwin':
            # disable on OSX, where there is always a menu bar
            self.toggle_menu_bar_act = QtWidgets.QAction("Toggle &Menu Bar",
                self,
                shortcut="Ctrl+Shift+M",
                statusTip="Toggle visibility of menubar",
                triggered=self.toggle_menu_bar)
            self.add_menu_action(self.view_menu, self.toggle_menu_bar_act)

        fs_key = "Ctrl+Meta+F" if sys.platform == 'darwin' else "F11"
        self.full_screen_act = QtWidgets.QAction("&Full Screen",
            self,
            shortcut=fs_key,
            statusTip="Toggle between Fullscreen and Normal Size",
            triggered=self.toggleFullScreen)
        self.add_menu_action(self.view_menu, self.full_screen_act)

        self.view_menu.addSeparator()

        self.increase_font_size = QtWidgets.QAction("Zoom &In",
            self,
            shortcut=QtGui.QKeySequence.ZoomIn,
            triggered=self.increase_font_size_active_frontend
            )
        self.add_menu_action(self.view_menu, self.increase_font_size, True)

        self.decrease_font_size = QtWidgets.QAction("Zoom &Out",
            self,
            shortcut=QtGui.QKeySequence.ZoomOut,
            triggered=self.decrease_font_size_active_frontend
            )
        self.add_menu_action(self.view_menu, self.decrease_font_size, True)

        self.reset_font_size = QtWidgets.QAction("Zoom &Reset",
            self,
            shortcut="Ctrl+0",
            triggered=self.reset_font_size_active_frontend
            )
        self.add_menu_action(self.view_menu, self.reset_font_size, True)

        self.view_menu.addSeparator()

        self.clear_action = QtWidgets.QAction("&Clear Screen",
            self,
            shortcut='Ctrl+L',
            statusTip="Clear the console",
            triggered=self.clear_active_frontend)
        self.add_menu_action(self.view_menu, self.clear_action)

        self.completion_menu = self.view_menu.addMenu("&Completion type")

        completion_group = QtWidgets.QActionGroup(self)
        active_frontend_completion = self.active_frontend.gui_completion
        ncurses_completion_action = QtWidgets.QAction(
            "&ncurses",
            self,
            triggered=lambda: self.set_completion_widget_active_frontend(
                'ncurses'))
        ncurses_completion_action.setCheckable(True)
        ncurses_completion_action.setChecked(
            active_frontend_completion == 'ncurses')
        droplist_completion_action = QtWidgets.QAction(
            "&droplist",
            self,
            triggered=lambda: self.set_completion_widget_active_frontend(
                'droplist'))
        droplist_completion_action.setCheckable(True)
        droplist_completion_action.setChecked(
            active_frontend_completion == 'droplist')
        plain_commpletion_action = QtWidgets.QAction(
            "&plain",
            self,
            triggered=lambda: self.set_completion_widget_active_frontend(
                'plain'))
        plain_commpletion_action.setCheckable(True)
        plain_commpletion_action.setChecked(
            active_frontend_completion == 'plain')

        completion_group.addAction(ncurses_completion_action)
        completion_group.addAction(droplist_completion_action)
        completion_group.addAction(plain_commpletion_action)

        self.completion_menu.addAction(ncurses_completion_action)
        self.completion_menu.addAction(droplist_completion_action)
        self.completion_menu.addAction(plain_commpletion_action)
        self.completion_menu.setDefaultAction(ncurses_completion_action)

        self.pager_menu = self.view_menu.addMenu("&Pager")

        hsplit_action = QtWidgets.QAction(".. &Horizontal Split",
            self,
            triggered=lambda: self.set_paging_active_frontend('hsplit'))

        vsplit_action = QtWidgets.QAction(" : &Vertical Split",
            self,
            triggered=lambda: self.set_paging_active_frontend('vsplit'))

        inside_action = QtWidgets.QAction("   &Inside Pager",
            self,
            triggered=lambda: self.set_paging_active_frontend('inside'))

        self.pager_menu.addAction(hsplit_action)
        self.pager_menu.addAction(vsplit_action)
        self.pager_menu.addAction(inside_action)

        available_syntax_styles = self.get_available_syntax_styles()
        if len(available_syntax_styles) > 0:
            self.syntax_style_menu = self.view_menu.addMenu("&Syntax Style")
            style_group = QtWidgets.QActionGroup(self)
            for style in available_syntax_styles:
                action = QtWidgets.QAction("{}".format(style), self,
                                       triggered=lambda v,
                                       syntax_style=style:
                                           self.set_syntax_style(
                                                   syntax_style=syntax_style))
                action.setCheckable(True)
                style_group.addAction(action)
                self.syntax_style_menu.addAction(action)
                if style == 'default':
                    action.setChecked(True)
                    self.syntax_style_menu.setDefaultAction(action)
Exemplo n.º 6
0
    def contextMenuEvent(self, event):
        """
		build a right-click context menu

		for a more advanced example, see
		https://stackoverflow.com/questions/20930764/how-to-add-a-right-click-menu-to-each-cell-of-qtableview-in-pyqt
		"""

        # only allow right-click menu for nodes/edges
        if self._type in ['nodes', 'edges']:
            # ok
            pass
        else:
            return

        row = self.currentRow()
        pos = event.pos()
        print('bTableWidget2.contextMenuEvent() row:', row, pos)

        myType = self.getCellValue('type', row=row)
        print('  todo: remove this ... none type is now type 0')
        if myType is None:
            myType = 0
        myTypeInt = int(myType)
        print('  myType:', myType)
        #print('    myType:', myType, type(myType))

        # make a popup allowing 'type' to be set
        menu = QtWidgets.QMenu()
        numTypes = 10  # type 0 is no type
        types = []
        for i in range(numTypes):
            types.append('Type ' + str(i))
        for typeIdx, type in enumerate(types):
            # make an action
            isChecked = myTypeInt == typeIdx

            menuStr = 'Type ' + str(typeIdx)
            currentAction = QtWidgets.QAction(menuStr,
                                              self,
                                              checkable=True,
                                              checked=isChecked)
            currentAction.setProperty('bAction',
                                      'setType')  # from (setType, setIsBad)
            currentAction.setProperty('bObjectType',
                                      self._type)  # (nodes, edges)
            currentAction.setProperty(
                'bNewValue', typeIdx)  # the selected type (0,1,2,3,...)
            currentAction.triggered.connect(self.menuActionHandler)
            # add to menu
            menuAction = menu.addAction(currentAction)

        menu.addSeparator()

        # get current state from table widget
        # todo: maybe get from backend data???
        myIsBad = self.getCellValue('isBad', row=row)  # this is a string
        if myIsBad == 'true':  # lowercase because of json filtering
            myIsBad = True
        elif myIsBad == 'false':
            myIsBad = False
        else:
            myIsBad = False

        #
        # on user selection of good/bad, set the selected object isBad key

        # bad
        badAction = QtWidgets.QAction('Bad',
                                      self,
                                      checkable=True,
                                      checked=myIsBad)
        badAction.setProperty('bAction',
                              'setIsBad')  # from (setType, setIsBad)
        badAction.setProperty('bObjectType', self._type)  # (nodes, edges)
        badAction.setProperty(
            'bNewValue', True)  # user selected 'bad' -->> set isBad to True
        badAction.triggered.connect(self.menuActionHandler)
        menuAction = menu.addAction(badAction)
        # good
        goodAction = QtWidgets.QAction('Good',
                                       self,
                                       checkable=True,
                                       checked=not myIsBad)
        goodAction.setProperty('bAction',
                               'setIsBad')  # from (setType, setIsBad)
        goodAction.setProperty('bObjectType', self._type)  # (nodes, edges)
        goodAction.setProperty(
            'bNewValue', False)  # user selected 'good' -->> set isBad to False
        goodAction.triggered.connect(self.menuActionHandler)
        menuAction = menu.addAction(goodAction)

        # user selection will trigger self.menuActionHandler()
        userAction = menu.exec_(self.mapToGlobal(pos))
Exemplo n.º 7
0
    def __init__(self, parent=None):
        super(MaxEntView, self).__init__(parent)
        self.grid = QtWidgets.QVBoxLayout(self)

        self._runs_selector = CyclicDataSelectorView(self)
        self._runs_selector.set_data_combo_box_label("Runs:")
        self._runs_selector.set_data_combo_box_label_width(50)

        self._period_selector = CyclicDataSelectorView(self)
        self._period_selector.set_data_combo_box_label("Period:")
        self._period_selector.set_data_combo_box_label_width(50)

        # add splitter for resizing
        splitter = QtWidgets.QSplitter(QtCore.Qt.Vertical)

        self.run = None
        # make table
        self.table = QtWidgets.QTableWidget(self)
        self.table.resize(800, 800)

        self.table.setRowCount(7)
        self.table.setColumnCount(2)
        self.table.setColumnWidth(0, 300)
        self.table.setColumnWidth(1, 300)
        self.table.verticalHeader().setVisible(False)
        self.table.horizontalHeader().setStretchLastSection(True)
        self.table.setHorizontalHeaderLabels(
            ("MaxEnt Property;Value").split(";"))
        table_utils.setTableHeaders(self.table)

        # populate table
        options = []

        table_utils.setRowName(self.table, 0, "Calculate by")
        self.method = table_utils.addComboToTable(self.table, 0, options)

        table_utils.setRowName(self.table, 1, "Phase Table")
        self.phase_table_combo = table_utils.addComboToTable(self.table, 1, options)

        table_utils.setRowName(self.table, 2, "Fit dead times")
        self.dead_box = table_utils.addCheckBoxToTable(self.table, True, 2)

        table_utils.setRowName(self.table, 3, "Output phase table")
        self.output_phase_box = table_utils.addCheckBoxToTable(
            self.table, False, 3)

        table_utils.setRowName(self.table, 4, "Output deadtimes")
        self.output_dead_box = table_utils.addCheckBoxToTable(
            self.table, False, 4)

        table_utils.setRowName(self.table, 5, "Output reconstructed data")
        self.output_data_box = table_utils.addCheckBoxToTable(
            self.table, False, 5)

        table_utils.setRowName(self.table, 6, "Output phase convergence")
        self.output_phase_evo_box = table_utils.addCheckBoxToTable(
            self.table, False, 6)

        self.table.resizeRowsToContents()

        # advanced options table
        self.advancedLabel = QtWidgets.QLabel("\n  Advanced Options")
        # make table
        self.tableA = QtWidgets.QTableWidget(self)
        self.tableA.resize(800, 800)

        self.tableA.setRowCount(7)
        self.tableA.setColumnCount(2)
        self.tableA.setColumnWidth(0, 300)
        self.tableA.setColumnWidth(1, 300)

        self.tableA.verticalHeader().setVisible(False)
        self.tableA.horizontalHeader().setStretchLastSection(True)

        self.tableA.setHorizontalHeaderLabels(
            ("Advanced Property;Value").split(";"))
        table_utils.setTableHeaders(self.tableA)

        table_utils.setRowName(self.tableA, 0, "Maximum entropy constant (A)")
        self.AConst, _ = table_utils.addDoubleToTable(self.tableA, 0.1, 0)

        table_utils.setRowName(self.tableA, 1, "Lagrange multiplier for chi^2")
        self.factor, _ = table_utils.addDoubleToTable(self.tableA, 1.04, 1)

        table_utils.setRowName(self.tableA, 2, "Inner Iterations")
        self.inner_loop = table_utils.addSpinBoxToTable(self.tableA, 10, 2)

        table_utils.setRowName(self.tableA, 3, "Outer Iterations")
        self.outer_loop = table_utils.addSpinBoxToTable(self.tableA, 10, 3)

        table_utils.setRowName(self.tableA, 4, "Double pulse data")
        self.double_pulse_box = table_utils.addCheckBoxToTable(
            self.tableA, False, 4)

        table_utils.setRowName(self.tableA, 5, "Number of data points")
        self.N_points = table_utils.addComboToTable(self.tableA, 5, options)

        table_utils.setRowName(self.tableA, 6, "Maximum Field ")
        self.max_field, _ = table_utils.addDoubleToTable(self.tableA, 1000.0, 6)

        # layout
        # this is if complex data is unhidden
        self.table.setMinimumSize(40, 203)
        self.tableA.setMinimumSize(40, 207)

        # make buttons
        self.button = QtWidgets.QPushButton('Calculate MaxEnt', self)
        self.button.setStyleSheet("background-color:lightgrey")
        self.cancel = QtWidgets.QPushButton('Cancel', self)
        self.cancel.setStyleSheet("background-color:lightgrey")
        self.cancel.setEnabled(False)
        # connects
        self.button.clicked.connect(self.MaxEntButtonClick)
        self.cancel.clicked.connect(self.cancelClick)
        # button layout
        self.buttonLayout = QtWidgets.QHBoxLayout()
        self.buttonLayout.addWidget(self.button)
        self.buttonLayout.addWidget(self.cancel)
        # add to layout
        self.grid.addWidget(self._runs_selector)
        self.grid.addWidget(self._period_selector)
        splitter.addWidget(self.table)
        splitter.addWidget(self.advancedLabel)
        splitter.addWidget(self.tableA)
        self.grid.addWidget(splitter)
        self.grid.addLayout(self.buttonLayout)
    def setup(self):

        # self.ui = QtGui.QScrollArea()
        # self.display_label = QtGui.QLabel("TestNPZView")
        self.ui = self.display_textEdit = QtWidgets.QTextEdit()
Exemplo n.º 9
0
    def _build(self):
        _layout = QtWidgets.QVBoxLayout(self)
        _layout.setSpacing(2)
        _layout.setContentsMargins(2, 2, 2, 2)

        # # current project widget
        # self.project_frame = QtWidgets.QFrame()
        # _layout.addWidget(self.project_frame)
        # self.project_layout = QtWidgets.QHBoxLayout(self.project_frame)
        # self.project_label = QtWidgets.QLabel()
        # self.project_label.setText(u'当前项目名:')
        # self.project_layout.addWidget(self.project_label)

        # contant widget
        self.contant_widget = QtWidgets.QFrame()
        _layout.addWidget(self.contant_widget)
        self.contant_layout = QtWidgets.QHBoxLayout(self.contant_widget)
        self.contant_layout.setSpacing(2)
        self.contant_layout.setContentsMargins(2,2,2,2)

        self.filter_widget = filter_widget.FilterWidget()
        self.contant_layout.addWidget(self.filter_widget)

        # scroll widget
        self.scroll_widget = QtWidgets.QScrollArea()
        self.contant_layout.addWidget(self.scroll_widget)
        self.scroll_widget.setWidgetResizable(True)
        self.scroll_widget.setBackgroundRole(QtGui.QPalette.NoRole)
        self.scroll_widget.setFrameShape(QtWidgets.QFrame.NoFrame)

        self.check_widget = QtWidgets.QFrame()
        self.scroll_widget.setWidget(self.check_widget)
        self.check_layout = QtWidgets.QVBoxLayout(self.check_widget)
        self.check_layout.setSpacing(0)
        self.check_layout.setContentsMargins(0,0,0,0)
         
        # self.check_infolayout = QtWidgets.QHBoxLayout()
        # self.check_infolayout.setContentsMargins(2,2,2,2)
        # self.check_layout.addLayout(self.check_infolayout)
        # self.check_label = QtWidgets.QLabel()
        # self.check_infolayout.addWidget(self.check_label) 
         
        self.check_listlayout = QtWidgets.QVBoxLayout()
        self.check_listlayout.setContentsMargins(2,2,2,2)
        self.check_layout.addLayout(self.check_listlayout)
        self.check_layout.addStretch(True)

        # operation widget
        self.operation_widget = QtWidgets.QWidget()
        _layout.addWidget(self.operation_widget)
        self.operation_layout = QtWidgets.QHBoxLayout(self.operation_widget)
        self.operation_layout.setSpacing(4)
        self.operation_layout.setContentsMargins(0,0,0,0)
        # show all item widget
        self.show_all_checkbox = QtWidgets.QCheckBox()
        self.show_all_checkbox.setText(u"显示所有检查面板")
        self.show_all_checkbox.setChecked(True)
        self.operation_layout.addWidget(self.show_all_checkbox)
        self.operation_layout.addStretch(True)
        # recheck button
        self.recheck_button = QtWidgets.QPushButton()
        self.recheck_button.setMinimumSize(100,30)
        self.operation_layout.addWidget(self.recheck_button)
        self.recheck_button.setText(u"检查")
Exemplo n.º 10
0
    def setupMenus(self):
        """
        Set up the main window menus.

        Popups are made of actions, items and separators.
        The `Window` menu is a special case due to its dynamic nature. Its
        contents depend on the number of existing views.
        In order to track changes and keep updated the menu, it is reloaded
        every time it is about to be displayed.
        """

        # Create the File menu and add actions/submenus/separators to it
        self.file_menu = self.menuBar().addMenu(
            translate('VTGUI', "&File", 'The File menu entry'))
        self.file_menu.setObjectName('file_menu')
        # The Open Recent submenu
        self.open_recent_submenu = QtWidgets.QMenu(
            translate('VTGUI', 'Open R&ecent Files',
                      'File -> Open Recent Files'))
        self.open_recent_submenu.setObjectName('open_recent_submenu')
        self.open_recent_submenu.setSeparatorsCollapsible(False)
        self.open_recent_submenu.setIcon(
            self.icons_dictionary['document-open-recent'])

        file_actions = [
            'fileNew', 'fileOpen', 'fileOpenRO', self.open_recent_submenu,
            None, 'fileClose', 'fileCloseAll', None, 'fileSaveAs', None,
            'fileExit'
        ]
        vitables.utils.addActions(self.file_menu, file_actions,
                                  self.gui_actions)

        file_open_button = self.file_toolbar.widgetForAction(
            self.gui_actions['fileOpen'])
        file_open_button.setMenu(self.open_recent_submenu)
        self.open_recent_submenu.aboutToShow.connect(self.updateRecentSubmenu)

        # Create the Node menu and add actions/submenus/separators to it
        self.node_menu = self.menuBar().addMenu(
            translate('VTGUI', "&Node", 'The Node menu entry'))
        self.node_menu.setObjectName('node_menu')
        node_actions = [
            'nodeOpen', 'nodeClose', 'nodeProperties', None, 'nodeNew',
            'nodeRename', 'nodeCut', 'nodeCopy', 'nodePaste', 'nodeDelete'
        ]
        vitables.utils.addActions(self.node_menu, node_actions,
                                  self.gui_actions)

        # Create the Dataset menu and add actions/submenus/separators to it
        self.dataset_menu = self.menuBar().addMenu(
            translate('VTGUI', "&Dataset", 'The Dataset menu entry'))
        self.dataset_menu.setObjectName('dataset_menu')
        dataset_actions = ['queryNew', 'calculate']
        vitables.utils.addActions(self.dataset_menu, dataset_actions,
                                  self.gui_actions)

        # Create the Settings menu and add actions/submenus/separators to it
        settings_menu = self.menuBar().addMenu(
            translate('VTGUI', "&Settings", 'The Settings menu entry'))
        settings_menu.setObjectName('settings_menu')
        # Returns a popup menu containing checkable entries for the toolbars
        # and dock widgets present in the main window
        self.toolbars_submenu = self.createPopupMenu()
        self.toolbars_submenu.setObjectName('settings_toolbars_submenu')
        self.toolbars_submenu.menuAction().setText(
            translate('VTGUI', 'ToolBars', 'Tools -> ToolBars action'))
        settings_actions = ['settingsPreferences', None, self.toolbars_submenu]
        vitables.utils.addActions(settings_menu, settings_actions,
                                  self.gui_actions)

        # Create the Window menu and add actions/menus/separators to it
        self.window_menu = self.menuBar().addMenu(
            translate('VTGUI', "&Window", 'The Windows menu entry'))
        self.window_menu.setObjectName('window_menu')
        windows_actions = [
            'windowCascade', 'windowTile', 'windowRestoreAll',
            'windowMinimizeAll', 'windowClose', 'windowCloseAll', None,
            'mdiTabbed', 'windowSeparator'
        ]
        vitables.utils.addActions(self.window_menu, windows_actions,
                                  self.gui_actions)
        self.window_menu.setSeparatorsCollapsible(True)
        self.window_menu.aboutToShow.connect(self.updateWindowMenu)

        # Create the Help menu and add actions/menus/separators to it
        help_menu = self.menuBar().addMenu(
            translate('VTGUI', "&Help", 'The Help menu entry'))
        help_menu.setObjectName('help_menu')
        help_actions = [
            'helpUsersGuide', None, 'helpAbout', 'helpAboutQt', 'helpVersions',
            None
        ]
        vitables.utils.addActions(help_menu, help_actions, self.gui_actions)
        whatis = QtWidgets.QWhatsThis.createAction(help_menu)
        whatis.setObjectName('whatis_help_menu')
        whatis.setStatusTip(
            translate('VTGUI', 'Context help',
                      'Status bar text for the Help -> Whats This action'))
        help_menu.addAction(whatis)

        #########################################################
        #
        # 				Context menus
        #
        #########################################################

        self.view_cm = QtWidgets.QMenu(self)
        self.view_cm.setObjectName('view_cm')
        actions = [
            'fileNew', 'fileOpen', 'fileOpenRO', self.open_recent_submenu,
            None, 'fileClose', 'fileCloseAll', None, 'fileSaveAs', None,
            'fileExit'
        ]
        vitables.utils.addActions(self.view_cm, actions, self.gui_actions)

        self.root_node_cm = QtWidgets.QMenu(self)
        self.root_node_cm.setObjectName('root_node_cm')
        actions = [
            'fileClose', 'fileSaveAs', None, 'nodeProperties', None, 'nodeNew',
            'nodeCopy', 'nodePaste', None, 'queryDeleteAll'
        ]
        vitables.utils.addActions(self.root_node_cm, actions, self.gui_actions)

        self.group_node_cm = QtWidgets.QMenu(self)
        self.group_node_cm.setObjectName('group_node_cm')
        actions = [
            'nodeProperties', None, 'nodeNew', 'nodeRename', 'nodeCut',
            'nodeCopy', 'nodePaste', 'nodeDelete'
        ]
        vitables.utils.addActions(self.group_node_cm, actions,
                                  self.gui_actions)

        self.leaf_node_cm = QtWidgets.QMenu(self)
        self.leaf_node_cm.setObjectName('leaf_node_cm')
        actions = [
            'nodeOpen', 'nodeClose', None, 'nodeProperties', None,
            'nodeRename', 'nodeCut', 'nodeCopy', 'nodePaste', 'nodeDelete',
            None, 'queryNew'
        ]
        vitables.utils.addActions(self.leaf_node_cm, actions, self.gui_actions)

        self.mdi_cm = QtWidgets.QMenu(self)
        self.mdi_cm.setObjectName('mdi_cm')
        actions = [self.window_menu]
        vitables.utils.addActions(self.mdi_cm, actions, self.gui_actions)
 def setup(self):
     self.ui = QtWidgets.QTextEdit("file_info")
Exemplo n.º 12
0
    def setupActions(self):
        """Provide actions to the menubar and the toolbars.
        """

        # Setting action names makes it easier to acces these actions
        # from plugins
        actions = {}
        actions['fileNew'] = QtWidgets.QAction(
            translate('VTGUI', '&New...', 'File -> New'),
            self,
            shortcut=QtGui.QKeySequence.New,
            triggered=self.vtapp.fileNew,
            icon=self.icons_dictionary['document-new'],
            statusTip=translate('VTGUI', 'Create a new file',
                                'Status bar text for the File -> New action'))
        actions['fileNew'].setObjectName('fileNew')

        actions['fileOpen'] = QtWidgets.QAction(
            translate('VTGUI', '&Open...', 'File -> Open'),
            self,
            shortcut=QtGui.QKeySequence.Open,
            triggered=self.vtapp.fileOpen,
            icon=self.icons_dictionary['document-open'],
            statusTip=translate('VTGUI', 'Open an existing file',
                                'Status bar text for the File -> Open action'))
        actions['fileOpen'].setObjectName('fileOpen')

        actions['fileOpenRO'] = QtWidgets.QAction(
            translate('VTGUI', 'Read-only open...', 'File -> Open'),
            self,
            triggered=self.vtapp.fileOpenRO,
            icon=self.icons_dictionary['document-open'],
            statusTip=translate('VTGUI',
                                'Open an existing file in read-only mode',
                                'Status bar text for the File -> Open action'))
        actions['fileOpenRO'].setObjectName('fileOpenRO')

        actions['fileClose'] = QtWidgets.QAction(
            translate('VTGUI', '&Close', 'File -> Close'),
            self,
            shortcut=QtGui.QKeySequence('Shift+F4'),
            triggered=self.vtapp.fileClose,
            icon=self.icons_dictionary['document-close'],
            statusTip=translate(
                'VTGUI', 'Close the selected file',
                'Status bar text for the File -> Close action'))
        actions['fileClose'].setObjectName('fileClose')

        actions['fileCloseAll'] = QtWidgets.QAction(
            translate('VTGUI', 'Close &All', 'File -> Close All'),
            self,
            triggered=self.vtapp.fileCloseAll,
            statusTip=translate(
                'VTGUI', 'Close all files',
                'Status bar text for the File -> Close All action'))
        actions['fileCloseAll'].setObjectName('fileCloseAll')

        actions['fileSaveAs'] = QtWidgets.QAction(
            translate('VTGUI', '&Save as...', 'File -> Save As'),
            self,
            shortcut=QtGui.QKeySequence.SaveAs,
            triggered=self.vtapp.fileSaveAs,
            icon=self.icons_dictionary['document-save-as'],
            statusTip=translate(
                'VTGUI', 'Save a renamed copy of the selected file',
                'Status bar text for the File -> Save As action'))
        actions['fileSaveAs'].setObjectName('fileSaveAs')

        actions['fileExit'] = QtWidgets.QAction(
            translate('VTGUI', 'E&xit', 'File -> Exit'),
            self,
            shortcut=QtGui.QKeySequence.Quit,
            triggered=self.close,
            icon=self.icons_dictionary['application-exit'],
            statusTip=translate('VTGUI', 'Quit ViTables',
                                'Status bar text for the File -> Exit action'))
        actions['fileExit'].setObjectName('fileExit')

        actions['nodeOpen'] = QtWidgets.QAction(
            translate('VTGUI', '&Open view', 'Node -> Open View'),
            self,
            shortcut=QtGui.QKeySequence('Alt+Ctrl+O'),
            triggered=self.vtapp.nodeOpen,
            statusTip=translate(
                'VTGUI', 'Display the contents of the selected node',
                'Status bar text for the Node -> Open View action'))
        actions['nodeOpen'].setObjectName('nodeOpen')

        actions['nodeClose'] = QtWidgets.QAction(
            translate('VTGUI', 'C&lose view', 'Node -> Close View'),
            self,
            shortcut=QtGui.QKeySequence('Alt+Shift+F4'),
            triggered=self.vtapp.nodeClose,
            statusTip=translate(
                'VTGUI', 'Close the view of the selected node',
                'Status bar text for the Node -> Close View action'))
        actions['nodeClose'].setObjectName('nodeClose')

        actions['nodeProperties'] = QtWidgets.QAction(
            translate('VTGUI', 'Prop&erties...', 'Node -> Properties'),
            self,
            shortcut=QtGui.QKeySequence('Ctrl+I'),
            triggered=self.vtapp.nodeProperties,
            icon=self.icons_dictionary['help-about'],
            statusTip=translate(
                'VTGUI', 'Show the properties dialog for the selected node',
                'Status bar text for the Node -> Properties action'))
        actions['nodeProperties'].setObjectName('nodeProperties')

        actions['nodeNew'] = QtWidgets.QAction(
            translate('VTGUI', '&New group...', 'Node -> New group'),
            self,
            shortcut=QtGui.QKeySequence('Alt+Ctrl+N'),
            triggered=self.vtapp.nodeNewGroup,
            icon=self.icons_dictionary['folder-new'],
            statusTip=translate(
                'VTGUI', 'Create a new group under the selected node',
                'Status bar text for the Node -> New group action'))
        actions['nodeNew'].setObjectName('nodeNew')

        actions['nodeRename'] = QtWidgets.QAction(
            translate('VTGUI', '&Rename...', 'Node -> Rename'),
            self,
            shortcut=QtGui.QKeySequence('Ctrl+R'),
            triggered=self.vtapp.nodeRename,
            icon=self.icons_dictionary['edit-rename'],
            statusTip=translate(
                'VTGUI', 'Rename the selected node',
                'Status bar text for the Node -> Rename action'))
        actions['nodeRename'].setObjectName('nodeRename')

        actions['nodeCut'] = QtWidgets.QAction(
            translate('VTGUI', 'Cu&t', 'Node -> Cut'),
            self,
            shortcut=QtGui.QKeySequence.Cut,
            triggered=self.vtapp.nodeCut,
            icon=self.icons_dictionary['edit-cut'],
            statusTip=translate('VTGUI', 'Cut the selected node',
                                'Status bar text for the Node -> Cut action'))
        actions['nodeCut'].setObjectName('nodeCut')

        actions['nodeCopy'] = QtWidgets.QAction(
            translate('VTGUI', '&Copy', 'Node -> Copy'),
            self,
            shortcut=QtGui.QKeySequence.Copy,
            triggered=self.makeCopy,
            icon=self.icons_dictionary['edit-copy'],
            statusTip=translate('VTGUI', 'Copy the selected node',
                                'Status bar text for the Node -> Copy action'))
        actions['nodeCopy'].setObjectName('nodeCopy')

        actions['nodePaste'] = QtWidgets.QAction(
            translate('VTGUI', '&Paste', 'Node -> Paste'),
            self,
            shortcut=QtGui.QKeySequence.Paste,
            triggered=self.vtapp.nodePaste,
            icon=self.icons_dictionary['edit-paste'],
            statusTip=translate('VTGUI', 'Paste the last copied/cut node',
                                'Status bar text for the Node -> Copy action'))
        actions['nodePaste'].setObjectName('nodePaste')

        actions['nodeDelete'] = QtWidgets.QAction(
            translate('VTGUI', '&Delete', 'Node -> Delete'),
            self,
            shortcut=QtGui.QKeySequence.Delete,
            triggered=self.vtapp.nodeDelete,
            icon=self.icons_dictionary['edit-delete'],
            statusTip=translate('VTGUI', 'Delete the selected node',
                                'Status bar text for the Node -> Copy action'))
        actions['nodeDelete'].setObjectName('nodeDelete')

        actions['queryNew'] = QtWidgets.QAction(
            translate('VTGUI', '&Query...', 'Query -> New...'),
            self,
            triggered=self.vtapp.newQuery,
            icon=self.icons_dictionary['view-filter'],
            statusTip=translate(
                'VTGUI', 'Create a new filter for the selected table',
                'Status bar text for the Query -> New... action'))
        actions['queryNew'].setObjectName('queryNew')

        actions['queryDeleteAll'] = QtWidgets.QAction(
            translate('VTGUI', 'Delete &All', 'Query -> Delete All'),
            self,
            triggered=self.vtapp.deleteAllQueries,
            icon=self.icons_dictionary['delete_filters'],
            statusTip=translate(
                'VTGUI', 'Remove all filters',
                'Status bar text for the Query -> Delete All action'))
        actions['queryDeleteAll'].setObjectName('queryDeleteAll')

        actions['settingsPreferences'] = QtWidgets.QAction(
            translate('VTGUI', '&Preferences...', 'Settings -> Preferences'),
            self,
            shortcut=QtGui.QKeySequence.Preferences,
            triggered=self.vtapp.settingsPreferences,
            icon=self.icons_dictionary['configure'],
            statusTip=translate(
                'VTGUI', 'Configure ViTables',
                'Status bar text for the Settings -> Preferences action'))
        actions['settingsPreferences'].setObjectName('settingsPreferences')

        actions['windowCascade'] = QtWidgets.QAction(
            translate('VTGUI', '&Cascade', 'Windows -> Cascade'),
            self,
            triggered=self.workspace.cascadeSubWindows,
            statusTip=translate(
                'VTGUI', 'Arranges open windows in a cascade pattern',
                'Status bar text for the Windows -> Cascade action'))
        actions['windowCascade'].setObjectName('windowCascade')

        actions['windowTile'] = QtWidgets.QAction(
            translate('VTGUI', '&Tile', 'Windows -> Tile'),
            self,
            triggered=self.workspace.tileSubWindows,
            statusTip=translate(
                'VTGUI', 'Arranges open windows in a tile pattern',
                'Status bar text for the Windows -> Tile action'))
        actions['windowTile'].setObjectName('windowTile')

        actions['windowRestoreAll'] = QtWidgets.QAction(
            translate('VTGUI', '&Restore All', 'Windows -> Restore All'),
            self,
            triggered=self.vtapp.windowRestoreAll,
            statusTip=translate(
                'VTGUI', 'Restore all minimized windows on the workspace',
                'Status bar text for the Windows -> Restore All action'))
        actions['windowRestoreAll'].setObjectName('windowRestoreAll')

        actions['windowMinimizeAll'] = QtWidgets.QAction(
            translate('VTGUI', '&Minimize All', 'Windows -> Minimize All'),
            self,
            triggered=self.vtapp.windowMinimizeAll,
            statusTip=translate(
                'VTGUI', 'Minimize all windows on the workspace',
                'Status bar text for the Windows -> Restore All action'))
        actions['windowMinimizeAll'].setObjectName('windowMinimizeAll')

        actions['windowClose'] = QtWidgets.QAction(
            translate('VTGUI', 'C&lose', 'Windows -> Close'),
            self,
            triggered=self.vtapp.windowClose,
            statusTip=translate(
                'VTGUI', 'Close the active view',
                'Status bar text for the Windows -> Close action'))
        actions['windowClose'].setObjectName('windowClose')

        actions['windowCloseAll'] = QtWidgets.QAction(
            translate('VTGUI', 'Close &All', 'Windows -> Close All'),
            self,
            triggered=self.vtapp.windowCloseAll,
            statusTip=translate(
                'VTGUI', 'Close all views',
                'Status bar text for the Windows -> Close All action'))
        actions['windowCloseAll'].setObjectName('windowCloseAll')

        actions['windowSeparator'] = QtWidgets.QAction(
            translate('VTGUI', 'Current View', 'Windows -> separator'), self)
        actions['windowSeparator'].setSeparator(True)
        actions['windowSeparator'].setObjectName('windowSeparator')

        actions['mdiTabbed'] = QtWidgets.QAction(
            translate('VTGUI', 'Toggle MDI/Tabs', 'MDI -> Tabbed'),
            self,
            triggered=self.changeMDIViewMode,
            statusTip=translate(
                'VTGUI',
                'Toggle workspace view mode between Tabs <--> Multi Document '
                'Interface', 'Status bar text for the MDI -> Tabbed action'))
        actions['mdiTabbed'].setObjectName('mdiTabbed')

        actions['helpUsersGuide'] = QtWidgets.QAction(
            translate('VTGUI', "&User's Guide", 'Help -> Users Guide'),
            self,
            shortcut=QtGui.QKeySequence.HelpContents,
            triggered=self.vtapp.helpBrowser,
            icon=self.icons_dictionary['help-contents'],
            statusTip=translate(
                'VTGUI', "Open the ViTables User's Guide",
                'Status bar text for the Help -> Users Guide action'))
        actions['helpUsersGuide'].setObjectName('helpUsersGuide')

        actions['helpAbout'] = QtWidgets.QAction(
            translate('VTGUI', '&About ViTables', 'Help -> About'),
            self,
            triggered=self.vtapp.helpAbout,
            icon=self.icons_dictionary['vitables_wm'],
            statusTip=translate(
                'VTGUI', 'Display information about ViTables',
                'Status bar text for the Help -> About action'))
        actions['helpAbout'].setObjectName('helpAbout')

        actions['helpAboutQt'] = QtWidgets.QAction(
            translate('VTGUI', 'About &Qt', 'Help -> About Qt'),
            self,
            triggered=self.vtapp.helpAboutQt,
            statusTip=translate(
                'VTGUI', 'Display information about the Qt library',
                'Status bar text for the Help -> About Qt action'))
        actions['helpAboutQt'].setObjectName('helpAboutQt')

        actions['helpVersions'] = QtWidgets.QAction(
            translate('VTGUI', 'Show &Versions', 'Help -> Show Versions'),
            self,
            triggered=self.vtapp.helpVersions,
            statusTip=translate(
                'VTGUI', 'Show the versions of the libraries used by ViTables',
                'Status bar text for the Help -> Show Versions action'))
        actions['helpVersions'].setObjectName('helpVersions')

        actions['calculate'] = QtWidgets.QAction(
            translate('VTGUI', 'Calculate...', 'Calculate action'),
            self,
            triggered=calculator.run,
            statusTip=translate('VTGUI', 'Run calculation on opened tables.',
                                'Action tip'))
        actions['calculate'].setObjectName('calculate')

        return actions
Exemplo n.º 13
0
    def __init__(self, parent=None, window_flags=None):
        super(FrequencyAnalysisGui, self).__init__(parent)
        if window_flags:
            self.setWindowFlags(window_flags)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setFocusPolicy(QtCore.Qt.StrongFocus)

        try:
            check_facility()
        except AttributeError as error:
            self.warning_popup(error.args[0])

        # initialise the data storing classes of the interface
        self.loaded_data = MuonLoadData()
        self.data_context = MuonDataContext('Frequency Domain Data',
                                            self.loaded_data)
        self.gui_context = MuonGuiContext()
        self.plot_panes_context = PlotPanesContext()
        self.group_pair_context = MuonGroupPairContext(
            self.data_context.check_group_contains_valid_detectors)
        self.corrections_context = CorrectionsContext(self.loaded_data)
        self.phase_context = PhaseTableContext()
        self.fitting_context = BasicFittingContext(
            allow_double_pulse_fitting=True)
        self.results_context = ResultsContext()

        self.frequency_context = FrequencyContext()

        self.context = FrequencyDomainAnalysisContext(
            muon_data_context=self.data_context,
            muon_gui_context=self.gui_context,
            muon_group_context=self.group_pair_context,
            corrections_context=self.corrections_context,
            muon_phase_context=self.phase_context,
            plot_panes_context=self.plot_panes_context,
            fitting_context=self.fitting_context,
            results_context=self.results_context,
            frequency_context=self.frequency_context)

        # create the dockable widget
        self.plot_widget = FrequencyAnalysisPlotWidget(self.context,
                                                       parent=self)

        self.dockable_plot_widget_window = PlottingDockWidget(
            parent=self, plotting_widget=self.plot_widget.view)
        self.dockable_plot_widget_window.setMinimumWidth(575)

        # Add dock widget to main Muon analysis window
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,
                           self.dockable_plot_widget_window)
        # Need this line to stop the bug where the dock window snaps back to its original size after resizing.
        # 0 argument is arbitrary and has no effect on fit widget size
        # This is a qt bug reported at (https://bugreports.qt.io/browse/QTBUG-65592)
        if QT_VERSION >= LooseVersion("5.6"):
            self.resizeDocks({self.dockable_plot_widget_window}, {1},
                             QtCore.Qt.Horizontal)

        # construct all the widgets.
        self.load_widget = LoadWidget(self.loaded_data, self.context, self)
        self.grouping_tab_widget = GroupingTabWidget(self.context, parent)
        self.corrections_tab = CorrectionsTabWidget(self.context, self)
        self.home_tab = HomeTabWidget(self.context, self)
        self.phase_tab = PhaseTabWidget(self.context, self)
        self.transform = TransformWidget(self.context,
                                         FFTWidget,
                                         MaxEntWidget,
                                         parent=self)
        self.fitting_tab = FittingTabWidget(self.context, self)
        self.seq_fitting_tab = SeqFittingTabWidget(
            self.context, self.fitting_tab.fitting_tab_model, self)
        self.results_tab = ResultsTabWidget(self.context.fitting_context,
                                            self.context, self)

        self.setup_tabs()
        self.help_widget = HelpWidget(self.context.window_title)

        central_widget = QtWidgets.QWidget()
        vertical_layout = QtWidgets.QVBoxLayout()

        vertical_layout.addWidget(self.load_widget.load_widget_view)
        vertical_layout.addWidget(self.tabs)
        vertical_layout.addWidget(self.help_widget.view)
        central_widget.setLayout(vertical_layout)

        self.disable_notifier = GenericObservable()
        self.disable_observer = GenericObserver(
            self.disable_notifier.notify_subscribers)
        self.enable_notifier = GenericObservable()
        self.enable_observer = GenericObserver(
            self.enable_notifier.notify_subscribers)
        self.setup_disable_notifier()
        self.setup_enable_notifier()

        self.setCentralWidget(central_widget)
        self.setWindowTitle(self.context.window_title)

        self.setup_load_observers()

        self.setup_gui_variable_observers()

        self.setup_grouping_changed_observers()

        self.setup_corrections_changed_observers()

        self.setup_instrument_changed_notifier()

        self.setup_group_calculation_enable_notifier()

        self.setup_group_calculation_disabler_notifier()

        self.setup_on_load_enabler()

        self.setup_on_load_disabler()

        self.setup_phase_quad_changed_notifier()

        self.setup_phase_table_changed_notifier()
        self.setup_fitting_notifier()

        self.setup_counts_calculation_finished_notifier()

        self.setup_asymmetry_pair_and_diff_calculations_finished_notifier()

        self.setup_transform()

        self.context.data_context.message_notifier.add_subscriber(
            self.grouping_tab_widget.group_tab_presenter.message_observer)
Exemplo n.º 14
0
    def __init__(self, window, data_file):
        QtWidgets.QWidget.__init__(self)
        self.window = window
        self.data_file = data_file

        # Widget
        self.setMinimumWidth(500)
        self.setMinimumHeight(200)
        self.setWindowTitle("Folder Selector - ClickPoints")
        self.layout = QtWidgets.QVBoxLayout(self)

        self.setWindowIcon(qta.icon("fa.folder-open"))
        """ """
        self.list = QtWidgets.QListWidget(self)
        self.layout.addWidget(self.list)
        self.list.itemSelectionChanged.connect(self.list_selected)

        group_box = QtWidgets.QGroupBox("Add Folder")
        self.group_box = group_box
        self.layout.addWidget(group_box)
        layout = QtWidgets.QVBoxLayout()
        group_box.setLayout(layout)
        """ """

        horizontal_layout = QtWidgets.QHBoxLayout()
        layout.addLayout(horizontal_layout)

        horizontal_layout.addWidget(QtWidgets.QLabel("Folder:"))

        self.text_input = QtWidgets.QLineEdit(self)
        self.text_input.setDisabled(True)
        horizontal_layout.addWidget(self.text_input)

        self.pushbutton_folder = QtWidgets.QPushButton('Select F&older', self)
        self.pushbutton_folder.pressed.connect(self.select_folder)
        horizontal_layout.addWidget(self.pushbutton_folder)

        self.pushbutton_file = QtWidgets.QPushButton('Select F&ile', self)
        self.pushbutton_file.pressed.connect(self.select_file)
        horizontal_layout.addWidget(self.pushbutton_file)
        """ """

        horizontal_layout = QtWidgets.QHBoxLayout()
        layout.addLayout(horizontal_layout)

        horizontal_layout.addWidget(QtWidgets.QLabel("Filter:"))

        self.text_input_filter = QtWidgets.QLineEdit(self)
        self.text_input_filter.setToolTip(
            "Use any expression with an wildcard * to filter the files in the selected folder."
        )
        horizontal_layout.addWidget(self.text_input_filter)
        """ """

        horizontal_layout = QtWidgets.QHBoxLayout()
        layout.addLayout(horizontal_layout)

        self.checkbox_subfolders = QtWidgets.QCheckBox("subfolders")
        self.checkbox_subfolders.setToolTip(
            "Add all the subfolders of the selected folder, too.")
        horizontal_layout.addWidget(self.checkbox_subfolders)
        self.checkbox_natsort = QtWidgets.QCheckBox("natsort")
        self.checkbox_natsort.setToolTip(
            "Use natural sorting of filenames. This will sort numbers correctly (e.g. not 1 10 2 3). Takes more time to load."
        )
        horizontal_layout.addWidget(self.checkbox_natsort)

        self.pushbutton_load = QtWidgets.QPushButton('Load', self)
        self.pushbutton_load.pressed.connect(self.add_folder)
        horizontal_layout.addWidget(self.pushbutton_load)

        self.pushbutton_delete = QtWidgets.QPushButton('Remove', self)
        self.pushbutton_delete.pressed.connect(self.remove_folder)
        horizontal_layout.addWidget(self.pushbutton_delete)
        """ """

        horizontal_layout = QtWidgets.QHBoxLayout()
        self.layout.addLayout(horizontal_layout)

        horizontal_layout.addStretch()

        self.pushbutton_Confirm = QtWidgets.QPushButton('O&k', self)
        self.pushbutton_Confirm.pressed.connect(self.close)
        horizontal_layout.addWidget(self.pushbutton_Confirm)

        self.update_folder_list()
        self.list.setCurrentRow(self.list.count() - 1)
Exemplo n.º 15
0
import mp_event_loop
import qt_multiprocessing
from qtpy import QtWidgets


class LabelProxy(qt_multiprocessing.WidgetProxy):
    PROXY_CLASS = QtWidgets.QLabel
    GETTERS = ['text']


if __name__ == '__main__':
    with qt_multiprocessing.AppEventLoop() as loop:
        mp_event_loop.Proxy.__loop__ = loop

        app = QtWidgets.QApplication([])

        lbl = LabelProxy("Hello")

        widg = QtWidgets.QDialog()
        lay = QtWidgets.QFormLayout()
        widg.setLayout(lay)

        # Form
        inp = QtWidgets.QLineEdit()
        btn = QtWidgets.QPushButton('Set Text')
        lay.addRow(inp, btn)

        def set_text():
            lbl.setText(inp.text())

        btn.clicked.connect(set_text)
Exemplo n.º 16
0
    def setupUi(self, DockWidget):
        DockWidget.setObjectName("DockWidget")
        DockWidget.resize(497, 566)
        self.dockWidgetContents = QtWidgets.QWidget()
        self.dockWidgetContents.setObjectName("dockWidgetContents")
        self.gridLayout_45 = QtWidgets.QGridLayout(self.dockWidgetContents)
        self.gridLayout_45.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_45.setObjectName("gridLayout_45")
        self.label_126 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_126.setFont(font)
        self.label_126.setObjectName("label_126")
        self.gridLayout_45.addWidget(self.label_126, 0, 3, 2, 1)
        self.label_124 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_124.setFont(font)
        self.label_124.setObjectName("label_124")
        self.gridLayout_45.addWidget(self.label_124, 0, 2, 2, 1)
        self.label_133 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_133.setFont(font)
        self.label_133.setObjectName("label_133")
        self.gridLayout_45.addWidget(self.label_133, 8, 0, 1, 2)
        self.groupBoxDis_2 = QtWidgets.QGroupBox(self.dockWidgetContents)
        self.groupBoxDis_2.setEnabled(False)
        self.groupBoxDis_2.setObjectName("groupBoxDis_2")
        self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.groupBoxDis_2)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.label_7 = QtWidgets.QLabel(self.groupBoxDis_2)
        self.label_7.setObjectName("label_7")
        self.verticalLayout_4.addWidget(self.label_7)
        self.gridLayout_45.addWidget(self.groupBoxDis_2, 2, 3, 1, 1)
        self.stackedWidget_2 = QtWidgets.QStackedWidget(
            self.dockWidgetContents)
        self.stackedWidget_2.setObjectName("stackedWidget_2")
        self.page1_2 = QtWidgets.QWidget()
        self.page1_2.setObjectName("page1_2")
        self.gridLayout_35 = QtWidgets.QGridLayout(self.page1_2)
        self.gridLayout_35.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_35.setObjectName("gridLayout_35")
        self.label_57 = QtWidgets.QLabel(self.page1_2)
        self.label_57.setObjectName("label_57")
        self.gridLayout_35.addWidget(self.label_57, 0, 0, 1, 1)
        self.stackedWidget_2.addWidget(self.page1_2)
        self.page2_2 = QtWidgets.QWidget()
        self.page2_2.setObjectName("page2_2")
        self.gridLayout_36 = QtWidgets.QGridLayout(self.page2_2)
        self.gridLayout_36.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_36.setObjectName("gridLayout_36")
        self.label_58 = QtWidgets.QLabel(self.page2_2)
        self.label_58.setObjectName("label_58")
        self.gridLayout_36.addWidget(self.label_58, 0, 0, 1, 1)
        self.stackedWidget_2.addWidget(self.page2_2)
        self.gridLayout_45.addWidget(self.stackedWidget_2, 5, 2, 1, 1)
        self.stackedWidgetDis_2 = QtWidgets.QStackedWidget(
            self.dockWidgetContents)
        self.stackedWidgetDis_2.setEnabled(False)
        self.stackedWidgetDis_2.setObjectName("stackedWidgetDis_2")
        self.page1Dis_2 = QtWidgets.QWidget()
        self.page1Dis_2.setObjectName("page1Dis_2")
        self.gridLayout_37 = QtWidgets.QGridLayout(self.page1Dis_2)
        self.gridLayout_37.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_37.setObjectName("gridLayout_37")
        self.label_113 = QtWidgets.QLabel(self.page1Dis_2)
        self.label_113.setObjectName("label_113")
        self.gridLayout_37.addWidget(self.label_113, 0, 0, 1, 1)
        self.stackedWidgetDis_2.addWidget(self.page1Dis_2)
        self.page2Dis_2 = QtWidgets.QWidget()
        self.page2Dis_2.setObjectName("page2Dis_2")
        self.gridLayout_38 = QtWidgets.QGridLayout(self.page2Dis_2)
        self.gridLayout_38.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_38.setObjectName("gridLayout_38")
        self.label_114 = QtWidgets.QLabel(self.page2Dis_2)
        self.label_114.setObjectName("label_114")
        self.gridLayout_38.addWidget(self.label_114, 0, 0, 1, 1)
        self.stackedWidgetDis_2.addWidget(self.page2Dis_2)
        self.gridLayout_45.addWidget(self.stackedWidgetDis_2, 5, 3, 1, 1)
        self.label_131 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_131.setFont(font)
        self.label_131.setObjectName("label_131")
        self.gridLayout_45.addWidget(self.label_131, 6, 0, 1, 1)
        self.frame_2 = QtWidgets.QFrame(self.dockWidgetContents)
        self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_2.setObjectName("frame_2")
        self.gridLayout_43 = QtWidgets.QGridLayout(self.frame_2)
        self.gridLayout_43.setObjectName("gridLayout_43")
        self.label_9 = QtWidgets.QLabel(self.frame_2)
        self.label_9.setObjectName("label_9")
        self.gridLayout_43.addWidget(self.label_9, 0, 0, 1, 1)
        self.gridLayout_45.addWidget(self.frame_2, 6, 2, 1, 1)
        self.frameDis_2 = QtWidgets.QFrame(self.dockWidgetContents)
        self.frameDis_2.setEnabled(False)
        self.frameDis_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frameDis_2.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frameDis_2.setObjectName("frameDis_2")
        self.gridLayout_40 = QtWidgets.QGridLayout(self.frameDis_2)
        self.gridLayout_40.setObjectName("gridLayout_40")
        self.label_8 = QtWidgets.QLabel(self.frameDis_2)
        self.label_8.setObjectName("label_8")
        self.gridLayout_40.addWidget(self.label_8, 0, 0, 1, 1)
        self.gridLayout_45.addWidget(self.frameDis_2, 6, 3, 1, 1)
        self.label_132 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_132.setFont(font)
        self.label_132.setObjectName("label_132")
        self.gridLayout_45.addWidget(self.label_132, 7, 0, 1, 2)
        self.groupBox_2 = QtWidgets.QGroupBox(self.dockWidgetContents)
        self.groupBox_2.setObjectName("groupBox_2")
        self.gridLayout_7 = QtWidgets.QGridLayout(self.groupBox_2)
        self.gridLayout_7.setObjectName("gridLayout_7")
        self.label_10 = QtWidgets.QLabel(self.groupBox_2)
        self.label_10.setObjectName("label_10")
        self.gridLayout_7.addWidget(self.label_10, 0, 0, 1, 1)
        self.gridLayout_45.addWidget(self.groupBox_2, 2, 2, 1, 1)
        self.mdiAreaDis_2 = QtWidgets.QMdiArea(self.dockWidgetContents)
        self.mdiAreaDis_2.setEnabled(False)
        self.mdiAreaDis_2.setObjectName("mdiAreaDis_2")
        self.subwindow1Dis_2 = QtWidgets.QWidget()
        self.subwindow1Dis_2.setObjectName("subwindow1Dis_2")
        self.verticalLayout_9 = QtWidgets.QVBoxLayout(self.subwindow1Dis_2)
        self.verticalLayout_9.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_9.setObjectName("verticalLayout_9")
        self.label_111 = QtWidgets.QLabel(self.subwindow1Dis_2)
        self.label_111.setObjectName("label_111")
        self.verticalLayout_9.addWidget(self.label_111)
        self.subwindow2Dis_2 = QtWidgets.QWidget()
        self.subwindow2Dis_2.setObjectName("subwindow2Dis_2")
        self.verticalLayout_10 = QtWidgets.QVBoxLayout(self.subwindow2Dis_2)
        self.verticalLayout_10.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_10.setObjectName("verticalLayout_10")
        self.label_112 = QtWidgets.QLabel(self.subwindow2Dis_2)
        self.label_112.setObjectName("label_112")
        self.verticalLayout_10.addWidget(self.label_112)
        self.gridLayout_45.addWidget(self.mdiAreaDis_2, 8, 3, 1, 1)
        self.label_127 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_127.setFont(font)
        self.label_127.setObjectName("label_127")
        self.gridLayout_45.addWidget(self.label_127, 2, 0, 1, 2)
        self.widget_2 = QtWidgets.QWidget(self.dockWidgetContents)
        self.widget_2.setObjectName("widget_2")
        self.gridLayout_39 = QtWidgets.QGridLayout(self.widget_2)
        self.gridLayout_39.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_39.setObjectName("gridLayout_39")
        self.label_59 = QtWidgets.QLabel(self.widget_2)
        self.label_59.setObjectName("label_59")
        self.gridLayout_39.addWidget(self.label_59, 0, 0, 1, 1)
        self.gridLayout_45.addWidget(self.widget_2, 7, 2, 1, 1)
        self.widgetDis_2 = QtWidgets.QWidget(self.dockWidgetContents)
        self.widgetDis_2.setEnabled(False)
        self.widgetDis_2.setObjectName("widgetDis_2")
        self.gridLayout_44 = QtWidgets.QGridLayout(self.widgetDis_2)
        self.gridLayout_44.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_44.setObjectName("gridLayout_44")
        self.label_125 = QtWidgets.QLabel(self.widgetDis_2)
        self.label_125.setObjectName("label_125")
        self.gridLayout_44.addWidget(self.label_125, 0, 0, 1, 1)
        self.gridLayout_45.addWidget(self.widgetDis_2, 7, 3, 1, 1)
        self.mdiArea_2 = QtWidgets.QMdiArea(self.dockWidgetContents)
        self.mdiArea_2.setObjectName("mdiArea_2")
        self.subwindow1_2 = QtWidgets.QWidget()
        self.subwindow1_2.setObjectName("subwindow1_2")
        self.verticalLayout_11 = QtWidgets.QVBoxLayout(self.subwindow1_2)
        self.verticalLayout_11.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_11.setObjectName("verticalLayout_11")
        self.label_29 = QtWidgets.QLabel(self.subwindow1_2)
        self.label_29.setObjectName("label_29")
        self.verticalLayout_11.addWidget(self.label_29)
        self.subwindow2_2 = QtWidgets.QWidget()
        self.subwindow2_2.setObjectName("subwindow2_2")
        self.verticalLayout_12 = QtWidgets.QVBoxLayout(self.subwindow2_2)
        self.verticalLayout_12.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_12.setObjectName("verticalLayout_12")
        self.label_56 = QtWidgets.QLabel(self.subwindow2_2)
        self.label_56.setObjectName("label_56")
        self.verticalLayout_12.addWidget(self.label_56)
        self.gridLayout_45.addWidget(self.mdiArea_2, 8, 2, 1, 1)
        self.label_128 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_128.setFont(font)
        self.label_128.setObjectName("label_128")
        self.gridLayout_45.addWidget(self.label_128, 3, 0, 1, 2)
        self.scrollArea_2 = QtWidgets.QScrollArea(self.dockWidgetContents)
        self.scrollArea_2.setWidgetResizable(True)
        self.scrollArea_2.setObjectName("scrollArea_2")
        self.scrollAreaWidgetContents_2 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_2.setGeometry(
            QtCore.QRect(0, 0, 181, 246))
        self.scrollAreaWidgetContents_2.setObjectName(
            "scrollAreaWidgetContents_2")
        self.verticalLayout_14 = QtWidgets.QVBoxLayout(
            self.scrollAreaWidgetContents_2)
        self.verticalLayout_14.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_14.setObjectName("verticalLayout_14")
        self.label_70 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2)
        self.label_70.setObjectName("label_70")
        self.verticalLayout_14.addWidget(self.label_70)
        self.label_71 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2)
        self.label_71.setObjectName("label_71")
        self.verticalLayout_14.addWidget(self.label_71)
        self.label_75 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2)
        self.label_75.setObjectName("label_75")
        self.verticalLayout_14.addWidget(self.label_75)
        self.label_76 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2)
        self.label_76.setObjectName("label_76")
        self.verticalLayout_14.addWidget(self.label_76)
        self.label_77 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2)
        self.label_77.setObjectName("label_77")
        self.verticalLayout_14.addWidget(self.label_77)
        self.label_78 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2)
        self.label_78.setObjectName("label_78")
        self.verticalLayout_14.addWidget(self.label_78)
        self.label_79 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2)
        self.label_79.setObjectName("label_79")
        self.verticalLayout_14.addWidget(self.label_79)
        self.label_80 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2)
        self.label_80.setObjectName("label_80")
        self.verticalLayout_14.addWidget(self.label_80)
        self.label_81 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2)
        self.label_81.setObjectName("label_81")
        self.verticalLayout_14.addWidget(self.label_81)
        self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_2)
        self.gridLayout_45.addWidget(self.scrollArea_2, 3, 2, 1, 1)
        self.scrollAreaDis_2 = QtWidgets.QScrollArea(self.dockWidgetContents)
        self.scrollAreaDis_2.setEnabled(False)
        self.scrollAreaDis_2.setWidgetResizable(True)
        self.scrollAreaDis_2.setObjectName("scrollAreaDis_2")
        self.scrollAreaWidgetContentsDis_2 = QtWidgets.QWidget()
        self.scrollAreaWidgetContentsDis_2.setGeometry(
            QtCore.QRect(0, 0, 181, 246))
        self.scrollAreaWidgetContentsDis_2.setObjectName(
            "scrollAreaWidgetContentsDis_2")
        self.verticalLayout_13 = QtWidgets.QVBoxLayout(
            self.scrollAreaWidgetContentsDis_2)
        self.verticalLayout_13.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_13.setObjectName("verticalLayout_13")
        self.label_115 = QtWidgets.QLabel(self.scrollAreaWidgetContentsDis_2)
        self.label_115.setObjectName("label_115")
        self.verticalLayout_13.addWidget(self.label_115)
        self.label_116 = QtWidgets.QLabel(self.scrollAreaWidgetContentsDis_2)
        self.label_116.setObjectName("label_116")
        self.verticalLayout_13.addWidget(self.label_116)
        self.label_117 = QtWidgets.QLabel(self.scrollAreaWidgetContentsDis_2)
        self.label_117.setObjectName("label_117")
        self.verticalLayout_13.addWidget(self.label_117)
        self.label_118 = QtWidgets.QLabel(self.scrollAreaWidgetContentsDis_2)
        self.label_118.setObjectName("label_118")
        self.verticalLayout_13.addWidget(self.label_118)
        self.label_119 = QtWidgets.QLabel(self.scrollAreaWidgetContentsDis_2)
        self.label_119.setObjectName("label_119")
        self.verticalLayout_13.addWidget(self.label_119)
        self.label_120 = QtWidgets.QLabel(self.scrollAreaWidgetContentsDis_2)
        self.label_120.setObjectName("label_120")
        self.verticalLayout_13.addWidget(self.label_120)
        self.label_121 = QtWidgets.QLabel(self.scrollAreaWidgetContentsDis_2)
        self.label_121.setObjectName("label_121")
        self.verticalLayout_13.addWidget(self.label_121)
        self.label_122 = QtWidgets.QLabel(self.scrollAreaWidgetContentsDis_2)
        self.label_122.setObjectName("label_122")
        self.verticalLayout_13.addWidget(self.label_122)
        self.label_123 = QtWidgets.QLabel(self.scrollAreaWidgetContentsDis_2)
        self.label_123.setObjectName("label_123")
        self.verticalLayout_13.addWidget(self.label_123)
        self.scrollAreaDis_2.setWidget(self.scrollAreaWidgetContentsDis_2)
        self.gridLayout_45.addWidget(self.scrollAreaDis_2, 3, 3, 1, 1)
        self.label_129 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_129.setFont(font)
        self.label_129.setObjectName("label_129")
        self.gridLayout_45.addWidget(self.label_129, 4, 0, 1, 2)
        self.toolBox_2 = QtWidgets.QToolBox(self.dockWidgetContents)
        self.toolBox_2.setObjectName("toolBox_2")
        self.page_3 = QtWidgets.QWidget()
        self.page_3.setGeometry(QtCore.QRect(0, 0, 196, 73))
        self.page_3.setObjectName("page_3")
        self.gridLayout_41 = QtWidgets.QGridLayout(self.page_3)
        self.gridLayout_41.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_41.setObjectName("gridLayout_41")
        self.label_60 = QtWidgets.QLabel(self.page_3)
        self.label_60.setObjectName("label_60")
        self.gridLayout_41.addWidget(self.label_60, 2, 0, 1, 1)
        self.toolBox_2.addItem(self.page_3, "")
        self.page_8 = QtWidgets.QWidget()
        self.page_8.setGeometry(QtCore.QRect(0, 0, 163, 38))
        self.page_8.setObjectName("page_8")
        self.gridLayout_42 = QtWidgets.QGridLayout(self.page_8)
        self.gridLayout_42.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_42.setObjectName("gridLayout_42")
        self.label_61 = QtWidgets.QLabel(self.page_8)
        self.label_61.setObjectName("label_61")
        self.gridLayout_42.addWidget(self.label_61, 0, 0, 1, 1)
        self.toolBox_2.addItem(self.page_8, "")
        self.gridLayout_45.addWidget(self.toolBox_2, 4, 2, 1, 1)
        self.toolBoxDis_2 = QtWidgets.QToolBox(self.dockWidgetContents)
        self.toolBoxDis_2.setEnabled(False)
        self.toolBoxDis_2.setObjectName("toolBoxDis_2")
        self.page_6 = QtWidgets.QWidget()
        self.page_6.setGeometry(QtCore.QRect(0, 0, 196, 73))
        self.page_6.setObjectName("page_6")
        self.gridLayout_29 = QtWidgets.QGridLayout(self.page_6)
        self.gridLayout_29.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_29.setObjectName("gridLayout_29")
        self.label_109 = QtWidgets.QLabel(self.page_6)
        self.label_109.setObjectName("label_109")
        self.gridLayout_29.addWidget(self.label_109, 2, 0, 1, 1)
        self.toolBoxDis_2.addItem(self.page_6, "")
        self.page_7 = QtWidgets.QWidget()
        self.page_7.setGeometry(QtCore.QRect(0, 0, 163, 38))
        self.page_7.setObjectName("page_7")
        self.gridLayout_34 = QtWidgets.QGridLayout(self.page_7)
        self.gridLayout_34.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_34.setObjectName("gridLayout_34")
        self.label_110 = QtWidgets.QLabel(self.page_7)
        self.label_110.setObjectName("label_110")
        self.gridLayout_34.addWidget(self.label_110, 0, 0, 1, 1)
        self.toolBoxDis_2.addItem(self.page_7, "")
        self.gridLayout_45.addWidget(self.toolBoxDis_2, 4, 3, 1, 1)
        self.label_130 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_130.setFont(font)
        self.label_130.setObjectName("label_130")
        self.gridLayout_45.addWidget(self.label_130, 5, 0, 1, 2)
        DockWidget.setWidget(self.dockWidgetContents)

        self.retranslateUi(DockWidget)
        self.stackedWidget_2.setCurrentIndex(1)
        self.stackedWidgetDis_2.setCurrentIndex(1)
        self.toolBox_2.setCurrentIndex(0)
        self.toolBoxDis_2.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(DockWidget)
Exemplo n.º 17
0
    def __init__(self, script_launcher):
        QtWidgets.QWidget.__init__(self)
        self.script_launcher = script_launcher

        # Widget
        self.setMinimumWidth(700)
        self.setMinimumHeight(400)
        self.setWindowTitle("Add-on Browser - ClickPoints")
        self.layout_main = QtWidgets.QHBoxLayout(self)
        self.layout = QtWidgets.QVBoxLayout()
        self.layout_main.addLayout(self.layout)
        self.layout2 = QtWidgets.QVBoxLayout()
        self.layout_main.addLayout(self.layout2)

        self.setWindowIcon(qta.icon("fa.code"))

        self.list2 = QtWidgets.QListWidget(self)
        self.layout.addWidget(self.list2)
        self.list2.itemSelectionChanged.connect(self.list_selected2)

        layout = QtWidgets.QHBoxLayout()
        self.layout.addLayout(layout)
        self.button_import = QtWidgets.QPushButton("Import")
        self.button_import.clicked.connect(self.importScript)
        layout.addWidget(self.button_import)
        layout.addStretch()

        layout2b = QtWidgets.QVBoxLayout()
        self.layout2.addLayout(layout2b)
        #self.nameDisplay = QtWidgets.QLabel(self)
        self.nameDisplay = QtWidgets.QTextEdit(self)
        self.nameDisplay.setReadOnly(True)
        self.nameDisplay.setMaximumHeight(37)
        self.nameDisplay.setStyleSheet(
            "border-width: 1px; border-bottom-width: 0px; border-color: darkgray; border-style: solid; /* just a single line */; border-top-right-radius: 0px; /* same radius as the QComboBox */;"
        )
        layout2b.setSpacing(0)
        layout2b.addWidget(self.nameDisplay)

        self.imageDisplay = QtWidgets.QLabel(self)
        #self.layout2.addWidget(self.imageDisplay)

        self.textDisplay = QtWidgets.QTextEdit(self)
        self.textDisplay.setReadOnly(True)
        self.textDisplay.setStyleSheet(
            "border-width: 1px; border-top-width: 0px; border-color: darkgray; border-style: solid; /* just a single line */; border-top-right-radius: 0px; /* same radius as the QComboBox */;"
        )
        layout2b.addWidget(self.textDisplay)

        self.layout_buttons = QtWidgets.QHBoxLayout()
        self.layout2.addLayout(self.layout_buttons)
        self.layout_buttons.addStretch()

        self.button_removeAdd = QtWidgets.QPushButton("Remove")
        self.button_removeAdd.clicked.connect(self.add_script)
        self.layout_buttons.addWidget(self.button_removeAdd)

        self.selected_script = None

        self.update_folder_list2()
Exemplo n.º 18
0
import ophyd
from ophyd import Component as Cpt, EpicsSignal, EpicsSignalRO, DeviceStatus
from typhon import TyphonSuite
from qtpy import QtWidgets


class PointDetectorDevice(ophyd.Device):
    mtr = Cpt(EpicsSignal, 'mtr', kind='hinted')
    exp = Cpt(EpicsSignal, 'exp', kind='config')
    det = Cpt(EpicsSignalRO, 'det', kind='hinted')
    acq = Cpt(EpicsSignal, 'acq', kind='omitted')
    busy = Cpt(EpicsSignalRO, 'busy', kind='omitted')

    def trigger(self):
        st = DeviceStatus(self)
        self.acq.put(1, callback=st._finished)
        return st


# this is to make sure typhon does not crash out
app = QtWidgets.QApplication.instance()
if app is None:
    app = QtWidgets.QApplication([b"python epics"])

pd = PointDetectorDevice('point:', name='pd')
point_suite = TyphonSuite.from_device(pd)
point_suite.show()
Exemplo n.º 19
0
    def setupUi(self, SearcherSettings):
        SearcherSettings.setObjectName("SearcherSettings")
        SearcherSettings.setWindowModality(QtCore.Qt.NonModal)
        SearcherSettings.resize(450, 211)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(SearcherSettings.sizePolicy().hasHeightForWidth())
        SearcherSettings.setSizePolicy(sizePolicy)
        SearcherSettings.setMinimumSize(QtCore.QSize(450, 0))
        SearcherSettings.setBaseSize(QtCore.QSize(0, 0))
        SearcherSettings.setStyleSheet("")
        self.gridLayout = QtWidgets.QGridLayout(SearcherSettings)
        self.gridLayout.setContentsMargins(-1, -1, -1, 6)
        self.gridLayout.setSpacing(6)
        self.gridLayout.setObjectName("gridLayout")
        self.verticalLayout_4 = QtWidgets.QVBoxLayout()
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.headerrow = QtWidgets.QHBoxLayout()
        self.headerrow.setObjectName("headerrow")
        self.projectTitle = QtWidgets.QLabel(SearcherSettings)
        font = QtGui.QFont()
        font.setPointSize(15)
        self.projectTitle.setFont(font)
        self.projectTitle.setAlignment(QtCore.Qt.AlignCenter)
        self.projectTitle.setObjectName("projectTitle")
        self.headerrow.addWidget(self.projectTitle)
        self.line_2 = QtWidgets.QFrame(SearcherSettings)
        self.line_2.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_2.setObjectName("line_2")
        self.headerrow.addWidget(self.line_2)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.headerrow.addItem(spacerItem)
        self.checkBox = QtWidgets.QCheckBox(SearcherSettings)
        self.checkBox.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.checkBox.setObjectName("checkBox")
        self.headerrow.addWidget(self.checkBox)
        self.windowsize_chk = QtWidgets.QCheckBox(SearcherSettings)
        self.windowsize_chk.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.windowsize_chk.setObjectName("windowsize_chk")
        self.headerrow.addWidget(self.windowsize_chk)
        self.verticalLayout_4.addLayout(self.headerrow)
        self.line = QtWidgets.QFrame(SearcherSettings)
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        self.verticalLayout_4.addWidget(self.line)
        self.secondrow = QtWidgets.QHBoxLayout()
        self.secondrow.setObjectName("secondrow")
        self.lang_cbox = QtWidgets.QComboBox(SearcherSettings)
        self.lang_cbox.setObjectName("lang_cbox")
        self.lang_cbox.addItem("")
        self.secondrow.addWidget(self.lang_cbox)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.secondrow.addItem(spacerItem1)
        self.label_3 = QtWidgets.QLabel(SearcherSettings)
        self.label_3.setObjectName("label_3")
        self.secondrow.addWidget(self.label_3)
        self.maxresults_txt = QtWidgets.QSpinBox(SearcherSettings)
        self.maxresults_txt.setMinimum(1)
        self.maxresults_txt.setMaximum(9999)
        self.maxresults_txt.setObjectName("maxresults_txt")
        self.secondrow.addWidget(self.maxresults_txt)
        self.inmemory_chk = QtWidgets.QCheckBox(SearcherSettings)
        self.inmemory_chk.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.inmemory_chk.setTristate(False)
        self.inmemory_chk.setObjectName("inmemory_chk")
        self.secondrow.addWidget(self.inmemory_chk)
        self.verticalLayout_4.addLayout(self.secondrow)
        self.thirdrow = QtWidgets.QHBoxLayout()
        self.thirdrow.setObjectName("thirdrow")
        self.label_2 = QtWidgets.QLabel(SearcherSettings)
        self.label_2.setObjectName("label_2")
        self.thirdrow.addWidget(self.label_2)
        self.defaulthotkey_txt = QtWidgets.QLineEdit(SearcherSettings)
        self.defaulthotkey_txt.setToolTip("")
        self.defaulthotkey_txt.setReadOnly(True)
        self.defaulthotkey_txt.setObjectName("defaulthotkey_txt")
        self.thirdrow.addWidget(self.defaulthotkey_txt)
        self.hotkey_icon = QtWidgets.QToolButton(SearcherSettings)
        self.hotkey_icon.setPopupMode(QtWidgets.QToolButton.InstantPopup)
        self.hotkey_icon.setObjectName("hotkey_icon")
        self.thirdrow.addWidget(self.hotkey_icon)
        self.verticalLayout_4.addLayout(self.thirdrow)
        self.fourthrow = QtWidgets.QHBoxLayout()
        self.fourthrow.setObjectName("fourthrow")
        self.label = QtWidgets.QLabel(SearcherSettings)
        self.label.setObjectName("label")
        self.fourthrow.addWidget(self.label)
        self.databasepath_txt = QtWidgets.QLineEdit(SearcherSettings)
        self.databasepath_txt.setObjectName("databasepath_txt")
        self.fourthrow.addWidget(self.databasepath_txt)
        self.dbpath_icon = QtWidgets.QToolButton(SearcherSettings)
        self.dbpath_icon.setObjectName("dbpath_icon")
        self.fourthrow.addWidget(self.dbpath_icon)
        self.verticalLayout_4.addLayout(self.fourthrow)
        self.fifthrow = QtWidgets.QHBoxLayout()
        self.fifthrow.setObjectName("fifthrow")
        self.label_4 = QtWidgets.QLabel(SearcherSettings)
        self.label_4.setObjectName("label_4")
        self.fifthrow.addWidget(self.label_4)
        self.test1_btn = QtWidgets.QPushButton(SearcherSettings)
        self.test1_btn.setObjectName("test1_btn")
        self.fifthrow.addWidget(self.test1_btn)
        self.cleardata_btn = QtWidgets.QPushButton(SearcherSettings)
        self.cleardata_btn.setObjectName("cleardata_btn")
        self.fifthrow.addWidget(self.cleardata_btn)
        self.verticalLayout_4.addLayout(self.fifthrow)
        self.line_3 = QtWidgets.QFrame(SearcherSettings)
        self.line_3.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_3.setObjectName("line_3")
        self.verticalLayout_4.addWidget(self.line_3)
        self.sixthrow = QtWidgets.QHBoxLayout()
        self.sixthrow.setObjectName("sixthrow")
        self.about_btn = QtWidgets.QToolButton(SearcherSettings)
        self.about_btn.setObjectName("about_btn")
        self.sixthrow.addWidget(self.about_btn)
        spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.sixthrow.addItem(spacerItem2)
        self.debuglevel_cbx = QtWidgets.QComboBox(SearcherSettings)
        self.debuglevel_cbx.setObjectName("debuglevel_cbx")
        self.debuglevel_cbx.addItem("")
        self.debuglevel_cbx.addItem("")
        self.debuglevel_cbx.addItem("")
        self.sixthrow.addWidget(self.debuglevel_cbx)
        self.debugflag_chk = QtWidgets.QCheckBox(SearcherSettings)
        self.debugflag_chk.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.debugflag_chk.setObjectName("debugflag_chk")
        self.sixthrow.addWidget(self.debugflag_chk)
        self.discard_btn = QtWidgets.QPushButton(SearcherSettings)
        self.discard_btn.setObjectName("discard_btn")
        self.sixthrow.addWidget(self.discard_btn)
        self.save_btn = QtWidgets.QPushButton(SearcherSettings)
        self.save_btn.setObjectName("save_btn")
        self.sixthrow.addWidget(self.save_btn)
        self.verticalLayout_4.addLayout(self.sixthrow)
        self.gridLayout.addLayout(self.verticalLayout_4, 0, 0, 1, 1)

        self.retranslateUi(SearcherSettings)
        QtCore.QMetaObject.connectSlotsByName(SearcherSettings)
Exemplo n.º 20
0
    def __init__(self, context, parent=None):
        super(ApplyPatches, self).__init__(parent=parent)
        self.context = context
        self.setWindowTitle(N_('Apply Patches'))
        self.setAcceptDrops(True)
        if parent is not None:
            self.setWindowModality(Qt.WindowModal)

        self.curdir = core.getcwd()
        self.inner_drag = False

        self.usage = QtWidgets.QLabel()
        self.usage.setText(
            N_("""
            <p>
                Drag and drop or use the <strong>Add</strong> button to add
                patches to the list
            </p>
            """))

        self.tree = PatchTreeWidget(parent=self)
        self.tree.setHeaderHidden(True)
        # pylint: disable=no-member
        self.tree.itemSelectionChanged.connect(self._tree_selection_changed)

        self.notifier = notifier = observable.Observable()
        self.diffwidget = diff.DiffWidget(context,
                                          notifier,
                                          self,
                                          is_commit=True)

        self.add_button = qtutils.create_toolbutton(
            text=N_('Add'), icon=icons.add(), tooltip=N_('Add patches (+)'))

        self.remove_button = qtutils.create_toolbutton(
            text=N_('Remove'),
            icon=icons.remove(),
            tooltip=N_('Remove selected (Delete)'))

        self.apply_button = qtutils.create_button(text=N_('Apply'),
                                                  icon=icons.ok())

        self.close_button = qtutils.close_button()

        self.add_action = qtutils.add_action(self, N_('Add'), self.add_files,
                                             hotkeys.ADD_ITEM)

        self.remove_action = qtutils.add_action(self, N_('Remove'),
                                                self.tree.remove_selected,
                                                hotkeys.DELETE,
                                                hotkeys.BACKSPACE,
                                                hotkeys.REMOVE_ITEM)

        self.top_layout = qtutils.hbox(defs.no_margin, defs.button_spacing,
                                       self.add_button, self.remove_button,
                                       qtutils.STRETCH, self.usage)

        self.bottom_layout = qtutils.hbox(defs.no_margin, defs.button_spacing,
                                          self.close_button, qtutils.STRETCH,
                                          self.apply_button)

        self.splitter = qtutils.splitter(Qt.Vertical, self.tree,
                                         self.diffwidget)

        self.main_layout = qtutils.vbox(defs.margin, defs.spacing,
                                        self.top_layout, self.splitter,
                                        self.bottom_layout)
        self.setLayout(self.main_layout)

        qtutils.connect_button(self.add_button, self.add_files)
        qtutils.connect_button(self.remove_button, self.tree.remove_selected)
        qtutils.connect_button(self.apply_button, self.apply_patches)
        qtutils.connect_button(self.close_button, self.close)

        self.init_state(None, self.resize, 666, 420)
Exemplo n.º 21
0
    def close_tab(self,current_tab):
        """ Called when you need to try to close a tab.

        It takes the number of the tab to be closed as argument, or a reference
        to the widget inside this tab
        """

        # let's be sure "tab" and "closing widget" are respectively the index
        # of the tab to close and a reference to the frontend to close
        if type(current_tab) is not int :
            current_tab = self.tab_widget.indexOf(current_tab)
        closing_widget=self.tab_widget.widget(current_tab)


        # when trying to be closed, widget might re-send a request to be
        # closed again, but will be deleted when event will be processed. So
        # need to check that widget still exists and skip if not. One example
        # of this is when 'exit' is sent in a slave tab. 'exit' will be
        # re-sent by this function on the master widget, which ask all slave
        # widgets to exit
        if closing_widget is None:
            return

        #get a list of all slave widgets on the same kernel.
        slave_tabs = self.find_slave_widgets(closing_widget)

        keepkernel = None #Use the prompt by default
        if hasattr(closing_widget,'_keep_kernel_on_exit'): #set by exit magic
            keepkernel = closing_widget._keep_kernel_on_exit
            # If signal sent by exit magic (_keep_kernel_on_exit, exist and not None)
            # we set local slave tabs._hidden to True to avoid prompting for kernel
            # restart when they get the signal. and then "forward" the 'exit'
            # to the main window
            if keepkernel is not None:
                for tab in slave_tabs:
                    tab._hidden = True
                if closing_widget in slave_tabs:
                    try :
                        self.find_master_tab(closing_widget).execute('exit')
                    except AttributeError:
                        self.log.info("Master already closed or not local, closing only current tab")
                        self.tab_widget.removeTab(current_tab)
                    self.update_tab_bar_visibility()
                    return

        kernel_client = closing_widget.kernel_client
        kernel_manager = closing_widget.kernel_manager

        if keepkernel is None and not closing_widget._confirm_exit:
            # don't prompt, just terminate the kernel if we own it
            # or leave it alone if we don't
            keepkernel = closing_widget._existing
        if keepkernel is None: #show prompt
            if kernel_client and kernel_client.channels_running:
                title = self.window().windowTitle()
                cancel = QtWidgets.QMessageBox.Cancel
                okay = QtWidgets.QMessageBox.Ok
                if closing_widget._may_close:
                    msg = "You are closing the tab : "+'"'+self.tab_widget.tabText(current_tab)+'"'
                    info = "Would you like to quit the Kernel and close all attached Consoles as well?"
                    justthis = QtWidgets.QPushButton("&No, just this Tab", self)
                    justthis.setShortcut('N')
                    closeall = QtWidgets.QPushButton("&Yes, close all", self)
                    closeall.setShortcut('Y')
                    # allow ctrl-d ctrl-d exit, like in terminal
                    closeall.setShortcut('Ctrl+D')
                    box = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Question,
                                            title, msg)
                    box.setInformativeText(info)
                    box.addButton(cancel)
                    box.addButton(justthis, QtWidgets.QMessageBox.NoRole)
                    box.addButton(closeall, QtWidgets.QMessageBox.YesRole)
                    box.setDefaultButton(closeall)
                    box.setEscapeButton(cancel)
                    pixmap = QtGui.QPixmap(self._app.icon.pixmap(QtCore.QSize(64,64)))
                    box.setIconPixmap(pixmap)
                    reply = box.exec_()
                    if reply == 1: # close All
                        for slave in slave_tabs:
                            background(slave.kernel_client.stop_channels)
                            self.tab_widget.removeTab(self.tab_widget.indexOf(slave))
                        kernel_manager.shutdown_kernel()
                        self.tab_widget.removeTab(current_tab)
                        background(kernel_client.stop_channels)
                    elif reply == 0: # close Console
                        if not closing_widget._existing:
                            # Have kernel: don't quit, just close the tab
                            closing_widget.execute("exit True")
                        self.tab_widget.removeTab(current_tab)
                        background(kernel_client.stop_channels)
                else:
                    reply = QtWidgets.QMessageBox.question(self, title,
                        "Are you sure you want to close this Console?"+
                        "\nThe Kernel and other Consoles will remain active.",
                        okay|cancel,
                        defaultButton=okay
                        )
                    if reply == okay:
                        self.tab_widget.removeTab(current_tab)
        elif keepkernel: #close console but leave kernel running (no prompt)
            self.tab_widget.removeTab(current_tab)
            background(kernel_client.stop_channels)
        else: #close console and kernel (no prompt)
            self.tab_widget.removeTab(current_tab)
            if kernel_client and kernel_client.channels_running:
                for slave in slave_tabs:
                    background(slave.kernel_client.stop_channels)
                    self.tab_widget.removeTab(self.tab_widget.indexOf(slave))
                if kernel_manager:
                    kernel_manager.shutdown_kernel()
                background(kernel_client.stop_channels)

        self.update_tab_bar_visibility()
Exemplo n.º 22
0
    def setupUi(self):
        self.setObjectName("BETDialog")
        self.resize(1000, 800)

        self.layout = QW.QGridLayout(self)
        self.layout.setObjectName("layout")

        # Isotherm display
        self.isoGraph = GraphView(self)
        self.isoGraph.setObjectName("isoGraph")
        self.layout.addWidget(self.isoGraph, 0, 0, 1, 1)

        # BET plot
        self.betGraph = GraphView(self)
        self.betGraph.setObjectName("betGraph")
        self.layout.addWidget(self.betGraph, 0, 1, 1, 1)

        # Rouquerol plot
        self.rouqGraph = GraphView(self)
        self.rouqGraph.setObjectName("rouqGraph")
        self.layout.addWidget(self.rouqGraph, 1, 1, 1, 1)

        # Options/results box

        self.optionsBox = QW.QGroupBox('Options', self)
        self.layout.addWidget(self.optionsBox, 1, 0, 1, 1)

        self.optionsLayout = QW.QGridLayout(self.optionsBox)
        self.pSlider = QHSpinBoxRangeSlider(parent=self,
                                            dec_pnts=2,
                                            slider_range=[0, 1, 0.01],
                                            values=[0, 1])
        self.pSlider.setMaximumHeight(50)
        self.pSlider.setEmitWhileMoving(False)
        self.optionsLayout.addWidget(self.pSlider, 0, 0, 1, 4)

        self.optionsLayout.addWidget(QW.QLabel("Fit (R):"), 1, 0, 1, 1)
        self.result_r = LabelResult(self)
        self.optionsLayout.addWidget(self.result_r, 1, 1, 1, 1)
        self.auto_button = QW.QPushButton('Auto-determine', self)
        self.optionsLayout.addWidget(self.auto_button, 1, 3, 1, 1)

        # description labels
        self.optionsLayout.addWidget(QW.QLabel("Calculated results:"), 2, 0, 1,
                                     2)
        self.optionsLayout.addWidget(LabelAlignRight("BET area:"), 3, 0, 1, 1)
        self.optionsLayout.addWidget(LabelAlignRight("C constant:"), 3, 2, 1,
                                     1)
        self.optionsLayout.addWidget(LabelAlignRight("Monolayer uptake:"), 4,
                                     0, 1, 1)
        self.optionsLayout.addWidget(LabelAlignRight("Monolayer pressure:"), 4,
                                     2, 1, 1)
        self.optionsLayout.addWidget(LabelAlignRight("Slope:"), 5, 0, 1, 1)
        self.optionsLayout.addWidget(LabelAlignRight("Intercept:"), 5, 2, 1, 1)

        # result labels
        self.result_bet = LabelResult(self)
        self.optionsLayout.addWidget(self.result_bet, 3, 1, 1, 1)
        self.result_c = LabelResult(self)
        self.optionsLayout.addWidget(self.result_c, 3, 3, 1, 1)
        self.result_mono_n = LabelResult(self)
        self.optionsLayout.addWidget(self.result_mono_n, 4, 1, 1, 1)
        self.result_mono_p = LabelResult(self)
        self.optionsLayout.addWidget(self.result_mono_p, 4, 3, 1, 1)
        self.result_slope = LabelResult(self)
        self.optionsLayout.addWidget(self.result_slope, 5, 1, 1, 1)
        self.result_intercept = LabelResult(self)
        self.optionsLayout.addWidget(self.result_intercept, 5, 3, 1, 1)

        self.optionsLayout.addWidget(QW.QLabel("Calculation output:"), 6, 0, 1,
                                     2)
        self.output = LabelOutput(self)
        self.optionsLayout.addWidget(self.output, 7, 0, 2, 4)

        # Bottom buttons
        self.buttonBox = QW.QDialogButtonBox(self)
        self.buttonBox.setOrientation(QC.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QW.QDialogButtonBox.Cancel
                                          | QW.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.layout.addWidget(self.buttonBox)

        self.retranslateUi()
        QC.QObject.connect(self.buttonBox, QC.SIGNAL("accepted()"),
                           self.accept)
        QC.QObject.connect(self.buttonBox, QC.SIGNAL("rejected()"),
                           self.reject)
        QC.QMetaObject.connectSlotsByName(self)
Exemplo n.º 23
0
    def init_edit_menu(self):
        self.edit_menu = self.menuBar().addMenu("&Edit")

        self.undo_action = QtWidgets.QAction("&Undo",
            self,
            shortcut=QtGui.QKeySequence.Undo,
            statusTip="Undo last action if possible",
            triggered=self.undo_active_frontend
            )
        self.add_menu_action(self.edit_menu, self.undo_action)

        self.redo_action = QtWidgets.QAction("&Redo",
            self,
            shortcut=QtGui.QKeySequence.Redo,
            statusTip="Redo last action if possible",
            triggered=self.redo_active_frontend)
        self.add_menu_action(self.edit_menu, self.redo_action)

        self.edit_menu.addSeparator()

        self.cut_action = QtWidgets.QAction("&Cut",
            self,
            shortcut=QtGui.QKeySequence.Cut,
            triggered=self.cut_active_frontend
            )
        self.add_menu_action(self.edit_menu, self.cut_action, True)

        self.copy_action = QtWidgets.QAction("&Copy",
            self,
            shortcut=QtGui.QKeySequence.Copy,
            triggered=self.copy_active_frontend
            )
        self.add_menu_action(self.edit_menu, self.copy_action, True)

        self.copy_raw_action = QtWidgets.QAction("Copy (&Raw Text)",
            self,
            shortcut="Ctrl+Shift+C",
            triggered=self.copy_raw_active_frontend
            )
        self.add_menu_action(self.edit_menu, self.copy_raw_action, True)

        self.paste_action = QtWidgets.QAction("&Paste",
            self,
            shortcut=QtGui.QKeySequence.Paste,
            triggered=self.paste_active_frontend
            )
        self.add_menu_action(self.edit_menu, self.paste_action, True)

        self.edit_menu.addSeparator()

        selectall = QtGui.QKeySequence(QtGui.QKeySequence.SelectAll)
        if selectall.matches("Ctrl+A") and sys.platform != 'darwin':
            # Only override the default if there is a collision.
            # Qt ctrl = cmd on OSX, so the match gets a false positive on OSX.
            selectall = "Ctrl+Shift+A"
        self.select_all_action = QtWidgets.QAction("Select Cell/&All",
            self,
            shortcut=selectall,
            triggered=self.select_all_active_frontend
            )
        self.add_menu_action(self.edit_menu, self.select_all_action, True)
Exemplo n.º 24
0
    def __init__(self, constraints, parent=None):
        """
        Parameters
        ----------
        constraints : dict
            The `contstraints` property of a :class:`~glue.core.fitters.BaseFitter1D`
            object
        parent : QtWidgets.QWidget (optional)
            The parent of this widget
        """
        super(ConstraintsWidget, self).__init__(parent)
        self.constraints = constraints

        self.layout = QtWidgets.QGridLayout()
        self.layout.setContentsMargins(2, 2, 2, 2)
        self.layout.setSpacing(4)

        self.setLayout(self.layout)

        self.layout.addWidget(QtWidgets.QLabel("Estimate"), 0, 1)
        self.layout.addWidget(QtWidgets.QLabel("Fixed"), 0, 2)
        self.layout.addWidget(QtWidgets.QLabel("Bounded"), 0, 3)
        self.layout.addWidget(QtWidgets.QLabel("Lower Bound"), 0, 4)
        self.layout.addWidget(QtWidgets.QLabel("Upper Bound"), 0, 5)

        self._widgets = {}
        names = sorted(list(self.constraints.keys()))

        for k in names:
            row = []
            w = QtWidgets.QLabel(k)
            row.append(w)

            v = QtGui.QDoubleValidator()
            e = QtWidgets.QLineEdit()
            e.setValidator(v)
            e.setText(str(constraints[k]['value'] or ''))
            row.append(e)

            w = QtWidgets.QCheckBox()
            w.setChecked(constraints[k]['fixed'])
            fix = w
            row.append(w)

            w = QtWidgets.QCheckBox()
            limits = constraints[k]['limits']
            w.setChecked(limits is not None)
            bound = w
            row.append(w)

            e = QtWidgets.QLineEdit()
            e.setValidator(v)
            if limits is not None:
                e.setText(str(limits[0]))
            row.append(e)

            e = QtWidgets.QLineEdit()
            e.setValidator(v)
            if limits is not None:
                e.setText(str(limits[1]))
            row.append(e)

            def unset(w):
                def result(active):
                    if active:
                        w.setChecked(False)

                return result

            fix.toggled.connect(unset(bound))
            bound.toggled.connect(unset(fix))

            self._widgets[k] = row

        for i, row in enumerate(names, 1):
            for j, widget in enumerate(self._widgets[row]):
                self.layout.addWidget(widget, i, j)
Exemplo n.º 25
0
    def __init__(self, context, parent=None):
        standard.Dialog.__init__(self, parent=parent)
        self.context = context
        self.setWindowTitle(N_('Recently Modified Files'))
        if parent is not None:
            self.setWindowModality(Qt.WindowModal)

        count = 8
        self.update_thread = UpdateFileListThread(context, count)

        self.count = standard.SpinBox(value=count,
                                      maxi=10000,
                                      suffix=N_(' commits ago'))

        self.count_label = QtWidgets.QLabel()
        self.count_label.setText(N_('Showing changes since'))

        self.refresh_button = qtutils.refresh_button(enabled=False)

        self.tree = GitTreeWidget(parent=self)
        self.tree_model = GitFileTreeModel(self)
        self.tree.setModel(self.tree_model)

        self.expand_button = qtutils.create_button(text=N_('Expand all'),
                                                   icon=icons.unfold())

        self.collapse_button = qtutils.create_button(text=N_('Collapse all'),
                                                     icon=icons.fold())

        self.edit_button = qtutils.edit_button(enabled=False, default=True)
        self.close_button = qtutils.close_button()

        self.top_layout = qtutils.hbox(defs.no_margin, defs.spacing,
                                       self.count_label, self.count,
                                       qtutils.STRETCH, self.refresh_button)

        self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing,
                                          self.close_button, qtutils.STRETCH,
                                          self.expand_button,
                                          self.collapse_button,
                                          self.edit_button)

        self.main_layout = qtutils.vbox(defs.margin, defs.spacing,
                                        self.top_layout, self.tree,
                                        self.button_layout)
        self.setLayout(self.main_layout)

        self.tree.selection_changed.connect(self.tree_selection_changed)
        self.tree.path_chosen.connect(self.edit_file)
        self.count.valueChanged.connect(self.count_changed)
        self.count.editingFinished.connect(self.refresh)

        thread = self.update_thread
        thread.result.connect(self.set_filenames, type=Qt.QueuedConnection)

        qtutils.connect_button(self.refresh_button, self.refresh)
        qtutils.connect_button(self.expand_button, self.tree.expandAll)
        qtutils.connect_button(self.collapse_button, self.tree.collapseAll)
        qtutils.connect_button(self.close_button, self.accept)
        qtutils.connect_button(self.edit_button, self.edit_selected)

        qtutils.add_action(self, N_('Refresh'), self.refresh, hotkeys.REFRESH)

        self.update_thread.start()
        self.init_size(parent=parent)
Exemplo n.º 26
0
    # Configure the style collection to use colors based on data types:
    connection_style.use_data_defined_colors = True

    view = qtpynodeeditor.FlowView(scene)
    view.setWindowTitle("Connection (data-defined) color example")
    view.resize(800, 600)

    node_a = scene.create_node(NaiveDataModel)
    node_b = scene.create_node(NaiveDataModel)

    scene.create_connection(
        node_a[PortType.output][0],
        node_b[PortType.input][0],
    )

    scene.create_connection(
        node_a[PortType.output][1],
        node_b[PortType.input][1],
    )

    return scene, view, [node_a, node_b]


if __name__ == '__main__':
    logging.basicConfig(level='DEBUG')
    app = QtWidgets.QApplication([])
    scene, view, nodes = main(app)
    view.show()
    app.exec_()
Exemplo n.º 27
0
    def __init__(self,
                 text="Enter object label",
                 parent=None,
                 labels=None,
                 sort_labels=True,
                 show_text_field=True,
                 completion='startswith',
                 fit_to_content=None,
                 flags=None):
        if fit_to_content is None:
            fit_to_content = {'row': False, 'column': True}
        self._fit_to_content = fit_to_content

        super(LabelDialog, self).__init__(parent)
        self.edit = LabelQLineEdit()
        self.edit.setPlaceholderText(text)
        self.edit.setValidator(labelme.utils.labelValidator())
        self.edit.editingFinished.connect(self.postProcess)
        if flags:
            self.edit.textChanged.connect(self.updateFlags)
        layout = QtWidgets.QVBoxLayout()
        if show_text_field:
            layout.addWidget(self.edit)
        # buttons
        self.buttonBox = bb = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal,
            self,
        )
        bb.button(bb.Ok).setIcon(labelme.utils.newIcon('done'))
        bb.button(bb.Cancel).setIcon(labelme.utils.newIcon('undo'))
        bb.accepted.connect(self.validate)
        bb.rejected.connect(self.reject)
        layout.addWidget(bb)
        # label_list
        self.labelList = QtWidgets.QListWidget()
        if self._fit_to_content['row']:
            self.labelList.setHorizontalScrollBarPolicy(
                QtCore.Qt.ScrollBarAlwaysOff)
        if self._fit_to_content['column']:
            self.labelList.setVerticalScrollBarPolicy(
                QtCore.Qt.ScrollBarAlwaysOff)
        self._sort_labels = sort_labels
        if labels:
            self.labelList.addItems(labels)
        if self._sort_labels:
            self.labelList.sortItems()
        else:
            self.labelList.setDragDropMode(
                QtWidgets.QAbstractItemView.InternalMove)
        self.labelList.currentItemChanged.connect(self.labelSelected)
        self.edit.setListWidget(self.labelList)
        layout.addWidget(self.labelList)
        # label_flags
        if flags is None:
            flags = {}
        self._flags = flags
        self.flagsLayout = QtWidgets.QVBoxLayout()
        self.resetFlags()
        layout.addItem(self.flagsLayout)
        self.edit.textChanged.connect(self.updateFlags)
        self.setLayout(layout)
        # completion
        completer = QtWidgets.QCompleter()
        if not QT5 and completion != 'startswith':
            logger.warn("completion other than 'startswith' is only "
                        "supported with Qt5. Using 'startswith'")
            completion = 'startswith'
        if completion == 'startswith':
            completer.setCompletionMode(QtWidgets.QCompleter.InlineCompletion)
            # Default settings.
            # completer.setFilterMode(QtCore.Qt.MatchStartsWith)
        elif completion == 'contains':
            completer.setCompletionMode(QtWidgets.QCompleter.PopupCompletion)
            completer.setFilterMode(QtCore.Qt.MatchContains)
        else:
            raise ValueError('Unsupported completion: {}'.format(completion))
        completer.setModel(self.labelList.model())
        self.edit.setCompleter(completer)
Exemplo n.º 28
0
def main(*args):
    import sys
    if len(args) == 0:
        args = sys.argv
    else:
        args = [sys.executable] + list(args)
    print("args", args)

    if len(args) > 1:
        if args[1] == "register" or args[1] == "install":
            from .includes.RegisterRegistry import install
            return install()
        elif args[1] == "unregister" or args[1] == "uninstall":
            from .includes.RegisterRegistry import install
            return install("uninstall")
        elif args[1] == "-v" or args[1] == "--version":
            import clickpoints
            print(clickpoints.__version__)
            return
        elif args[1] == "ffmpeg":
            import imageio
            import glob
            import os
            # check for ffmpeg
            try:
                # check if imageio already has an exe file
                imageio.plugins.ffmpeg.get_exe()
                print("ffmpeg found from imageio")
            except imageio.core.fetching.NeedDownloadError:
                # try to find an ffmpeg.exe in the ClickPoints folder
                files = glob.glob(
                    os.path.join(os.path.dirname(__file__), "..",
                                 "ffmpeg*.exe"))
                files.extend(
                    glob.glob(
                        os.path.join(os.path.dirname(__file__), "..",
                                     "external", "ffmpeg*.exe")))
                # if an ffmpeg exe has been found, set the environmental variable accordingly
                if len(files):
                    print("ffmpeg found", files[0])
                    os.environ['IMAGEIO_FFMPEG_EXE'] = files[0]
                # if not, try to download it
                else:
                    print("try to download ffmpeg")
                    imageio.plugins.ffmpeg.download()
            return

    from clickpoints import print_status
    # print
    print_status()
    """ some magic to prevent PyQt5 from swallowing exceptions """
    # Back up the reference to the exceptionhook
    sys._excepthook = sys.excepthook
    # Set the exception hook to our wrapping function
    sys.excepthook = lambda *args: sys._excepthook(*args)

    from qtpy import QtCore, QtWidgets, QtGui
    import sys
    import ctypes
    from clickpoints.Core import ClickPointsWindow
    from clickpoints.includes import LoadConfig
    import quamash
    import asyncio

    from clickpoints import define_paths

    define_paths()

    app = QtWidgets.QApplication(args)
    loop = quamash.QEventLoop(app)
    asyncio.set_event_loop(loop)
    app.loop = loop

    # set an application id, so that windows properly stacks them in the task bar
    if sys.platform[:3] == 'win':
        myappid = 'fabrybiophysics.clickpoints'  # arbitrary string
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

    # load config and exec addon code
    config = LoadConfig(*args)

    with loop:
        # init and open the ClickPoints window
        window = ClickPointsWindow(config, app)
        window.show()
        loop.run_forever()
Exemplo n.º 29
0
 def __init__(self):
     super().__init__(QtW.QGroupBox, "", "", "")
     self._btn_group = QtW.QButtonGroup(self._qwidget)
     self._mgui_set_orientation("vertical")
     self._btn_group.buttonToggled.connect(self._emit_data)
Exemplo n.º 30
0
    def __init__(self, parent, app: FastFlixApp):
        self.main = parent.main
        self.app = app
        self.paused = False
        self.encode_paused = False
        self.encoding = False
        top_layout = QtWidgets.QHBoxLayout()

        top_layout.addWidget(QtWidgets.QLabel(t("Queue")))
        top_layout.addStretch(1)

        self.clear_queue = QtWidgets.QPushButton(
            self.app.style().standardIcon(
                QtWidgets.QStyle.SP_LineEditClearButton), t("Clear Completed"))
        self.clear_queue.clicked.connect(self.clear_complete)
        self.clear_queue.setFixedWidth(120)
        self.clear_queue.setToolTip(t("Remove completed tasks"))

        self.pause_queue = QtWidgets.QPushButton(
            self.app.style().standardIcon(QtWidgets.QStyle.SP_MediaPause),
            t("Pause Queue"))
        self.pause_queue.clicked.connect(self.pause_resume_queue)
        # pause_queue.setFixedHeight(40)
        self.pause_queue.setFixedWidth(120)
        self.pause_queue.setToolTip(
            t("Wait for the current command to finish,"
              " and stop the next command from processing"))

        self.pause_encode = QtWidgets.QPushButton(
            self.app.style().standardIcon(QtWidgets.QStyle.SP_MediaPause),
            t("Pause Encode"))
        self.pause_encode.clicked.connect(self.pause_resume_encode)
        # pause_queue.setFixedHeight(40)
        self.pause_encode.setFixedWidth(120)
        self.pause_encode.setToolTip(t("Pause / Resume the current command"))

        self.after_done_combo = QtWidgets.QComboBox()
        self.after_done_combo.addItem("None")
        actions = set()
        if reusables.win_based:
            actions.update(done_actions["windows"].keys())

        elif sys.platform == "darwin":
            actions.update(["shutdown", "restart"])
        else:
            actions.update(done_actions["linux"].keys())
        if self.app.fastflix.config.custom_after_run_scripts:
            actions.update(self.app.fastflix.config.custom_after_run_scripts)

        self.after_done_combo.addItems(sorted(actions))
        self.after_done_combo.setToolTip(
            "Run a command after conversion completes")
        self.after_done_combo.currentIndexChanged.connect(
            lambda: self.set_after_done())
        self.after_done_combo.setMaximumWidth(150)
        top_layout.addWidget(QtWidgets.QLabel(t("After Conversion")))
        top_layout.addWidget(self.after_done_combo, QtCore.Qt.AlignRight)
        top_layout.addWidget(self.pause_encode, QtCore.Qt.AlignRight)
        top_layout.addWidget(self.pause_queue, QtCore.Qt.AlignRight)
        top_layout.addWidget(self.clear_queue, QtCore.Qt.AlignRight)

        super().__init__(app,
                         parent,
                         t("Queue"),
                         "queue",
                         top_row_layout=top_layout)
        try:
            self.queue_startup_check()
        except Exception:
            logger.exception(
                "Could not load queue as it is outdated or malformed. Deleting for safety."
            )
            save_queue([],
                       queue_file=self.app.fastflix.queue_path,
                       config=self.app.fastflix.config)