Beispiel #1
0
    def __init__(self):

        app = application()

        self.tab_widget = QtWidgets.QTabWidget()

        self.main_window = QtWidgets.QMainWindow()
        self.main_window.setWindowTitle('Standard Icons')
        self.main_window.setCentralWidget(self.tab_widget)
        self.main_window.closeEvent = self.close_event

        # add a progress bar to the status bar
        self.progress_bar = QtWidgets.QProgressBar(
            self.main_window.statusBar())
        self.progress_bar.setAlignment(QtCore.Qt.AlignCenter)
        self.main_window.statusBar().addPermanentWidget(self.progress_bar)
        self.main_window.showMaximized()

        self.num_icons = 0
        self.file_index = 0
        self.zoom_widget = QtWidgets.QDialog()
        self.zoom_widget.setSizeGripEnabled(True)
        self.zoom_widget.resize(QtCore.QSize(256, 256))
        self.zoom_widget.setWindowFlags(QtCore.Qt.WindowCloseButtonHint)
        vbox = QtWidgets.QVBoxLayout()
        self.zoom_label = QtWidgets.QLabel()
        self.zoom_label.setScaledContents(True)
        vbox.addWidget(self.zoom_label)
        self.zoom_widget.setLayout(vbox)

        qt_icons = [sp for sp in dir(QtWidgets.QStyle) if sp.startswith('SP_')]

        self.windows_files = [
            'accessibilitycpl', 'compstui', 'ddores', 'dmdskres', 'explorer',
            'gameux', 'ieframe', 'imageres', 'mmcndmgr', 'mmres', 'moricons',
            'netcenter', 'netshell', 'networkexplorer', 'pifmgr', 'pnidui',
            'sensorscpl', 'setupapi', 'shell32', 'wmploc', 'wpdshext'
        ]

        self.num_files = 1 + len(self.windows_files)
        self.progress_bar.setRange(0, self.num_files)

        self.add_qt_tab('Qt Icons', qt_icons)

        if has_clr:
            self.windows_index = 0
            self.timer = QtCore.QTimer()
            self.timer.timeout.connect(self.add_windows_tab)
            self.timer.start(0)
        else:
            self.update_message('Loaded {} icons.'.format(self.num_icons))
            self.progress_bar.hide()

        app.exec()
    def __init__(self, parent=None):
        """A :class:`~QtWidgets.QWidget` to view a
        :ref:`Configuration File <msl.equipment:configuration_file>`.

        Parameters
        ----------
        parent : :class:`QtWidgets.QWidget`, optional
            The parent :class:`QtWidgets.QWidget`.

        Example
        -------
        To view an example of the :class:`ConfigurationViewer`, run:

        >>> from msl.examples.qt.equipment import configuration_viewer # doctest: +SKIP
        >>> configuration_viewer.show() # doctest: +SKIP
        """
        super(ConfigurationViewer, self).__init__(parent=parent)

        if not has_msl_equipment:
            raise ImportError(
                'This class requires that MSL Equipment is installed')

        self.setAcceptDrops(True)
        self._dropped_path = None
        self._database = None

        #
        # selecting a configuration file
        #
        browse = Button(icon=QtWidgets.QStyle.SP_DialogOpenButton)
        browse.setToolTip('Select a configuration file')
        browse.set_left_click(self._browse_file)

        self._filebox = QtWidgets.QLineEdit()
        self._filebox.setToolTip('Drag \'n drop a configuration file')
        self._filebox.setReadOnly(True)

        select_layout = QtWidgets.QHBoxLayout()
        select_layout.addWidget(browse)
        select_layout.addWidget(self._filebox)
        select_layout.setSpacing(1)

        #
        # the filter field
        #
        self._filter = QtWidgets.QLineEdit()
        self._filter.setToolTip('Search filter for the database')
        self._filter.returnPressed.connect(self._apply_filter)

        filter_button = Button(icon=QtWidgets.QStyle.SP_FileDialogContentsView,
                               tooltip='Apply filter')
        filter_button.set_left_click(self._apply_filter)

        clear_button = Button(icon=QtWidgets.QStyle.SP_LineEditClearButton,
                              tooltip='Clear filter')
        clear_button.set_left_click(self._clear_filter)

        filter_layout = QtWidgets.QHBoxLayout()
        filter_layout.addWidget(filter_button)
        filter_layout.addWidget(self._filter)
        filter_layout.addWidget(clear_button)
        filter_layout.setSpacing(1)

        #
        # the Tree and Tables
        #
        self._equipment_records_table = _RecordTable(EquipmentRecord, self)
        self._connection_records_table = _RecordTable(ConnectionRecord, self)
        self._equipment_table = _RecordTable(EquipmentRecord,
                                             self,
                                             is_dict=True)
        self._constants_table = _ConstantsTable(self)

        self._tree = _Tree(self._equipment_records_table,
                           self._connection_records_table)
        self._tree.sig_selected.connect(self._tree_item_selected)
        self._tree.setToolTip(
            'Double click an item to select it.\n\nHold the CTRL key to select multiple items.'
        )

        tab = QtWidgets.QTabWidget()
        tab.addTab(self._equipment_records_table, 'Equipment Records')
        tab.addTab(self._connection_records_table, 'Connection Records')
        tab.addTab(self._equipment_table, 'Equipment Tags')
        tab.addTab(self._constants_table, 'Constants')
        tab.addTab(Logger(), 'Log')

        splitter = QtWidgets.QSplitter()
        splitter.addWidget(self._tree)
        splitter.addWidget(tab)
        splitter.setStretchFactor(1,
                                  1)  # the tab expands to fill the full width
        splitter.setSizes((self._tree.sizeHint().width() * 1.1, 1))

        main_layout = QtWidgets.QVBoxLayout()
        main_layout.addLayout(select_layout)
        main_layout.addLayout(filter_layout)
        main_layout.addWidget(splitter)

        self.setLayout(main_layout)