コード例 #1
0
ファイル: show_standard_icons.py プロジェクト: MSLNZ/msl-qt
    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()
コード例 #2
0
    def __init__(self, parent=None):
        super(BlinkingLEDs, self).__init__(parent)

        self.setWindowTitle('Blinking LEDs')

        # The shape can be an enum value or member name (case in-sensitive)
        # The color can be anything that msl.qt.utils.to_qcolor() accepts
        params = [
            {
                'shape': LED.Circle,
                'on_color': Qt.darkGreen,
                'clickable': True
            },
            {
                'shape': 'rouNDed',
                'on_color': (78, 82, 107)
            },
            {
                'shape': 2,
                'on_color': 'cyan',
                'clickable': True
            },
            {
                'shape': 'Triangle',
                'on_color': '#6b3064'
            },
        ]

        self.leds = []
        layout = QtWidgets.QHBoxLayout()
        for kwargs in params:
            led = LED(**kwargs)
            led.toggled.connect(self.led_state_changed)
            led.clicked.connect(self.led_was_clicked)
            layout.addWidget(led)
            self.leds.append(led)
        self.setLayout(layout)

        self._timer = QtCore.QTimer()
        self._timer.timeout.connect(self.toggle_random_led)
        self._timer.start(200)