Python PyQt5.QtWidgets.QWidget() Examples

The following are code examples for showing how to use PyQt5.QtWidgets.QWidget(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: libView   Author: liyanqing1987   File: libView.py    GNU General Public License v2.0 6 votes vote down vote up
def initTabWidget(self):
        """
        Init self.tabWidget.
        """
        self.areaTab = QWidget()
        self.leakagePowerTab = QWidget()
        self.timingTab = QWidget()
        self.internalPowerTab = QWidget()

        self.tabWidget.addTab(self.areaTab, 'Area')
        self.tabWidget.addTab(self.leakagePowerTab, 'Leakage Power')
        self.tabWidget.addTab(self.timingTab, 'Timing')
        self.tabWidget.addTab(self.internalPowerTab, 'Internal Power')

        self.tabWidget.currentChanged.connect(self.tabWidgetCurrentChanged)

        # Init sub-tabs.
        self.initAreaTab()
        self.initLeakagePowerTab()
        self.initTimingTab()
        self.initInternalPowerTab() 
Example 2
Project: ILTIS   Author: grg2rsr   File: MainWindow_Widget.py    GNU General Public License v2.0 6 votes vote down vote up
def setup_ToolBar(self):

        # spacer widget for right, have to be two different objects
        spacers = [QtWidgets.QWidget(),QtWidgets.QWidget()]
        for spacer in spacers:
            spacer.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)

        self.ToolBar = self.addToolBar('Hide')
        self.ToolBar.addWidget(spacers[0])
        self.ToolBar.addAction(self.toggledFFAction)
        self.ToolBar.addAction(self.toggleMonochromeAction)
        self.ToolBar.addAction(self.toggleAvgAction)
        self.ToolBar.addAction(self.toggleGlobalLevels)
        self.ToolBar.addAction(self.OpenOptionsAction)
        self.ToolBar.addWidget(spacers[1])
        pass 
Example 3
Project: idasec   Author: RobinDavid   File: generic_analysis.py    GNU Lesser General Public License v2.1 6 votes vote down vote up
def __init__(self, parent):
        QtWidgets.QWidget.__init__(self)
        self.setupUi(self)
        self.parent = parent
        # self.result_area.setEnabled(False)
        if self.parent.results.get_formula:
            self.formula_label.setVisible(True)
            self.formula_area.setEnabled(True)
        else:
            self.formula_label.setVisible(False)
            self.formula_area.setVisible(False)
        self.action_selector.setEnabled(False)
        self.action_button.setEnabled(False)
        self.action_selector.addItem(self.parent.ANNOT_CODE)
        self.action_button.clicked.connect(self.action_clicked)
        self.action_selector.currentIndexChanged[str].connect(self.action_selector_changed) 
Example 4
Project: kucher   Author: Zubax   File: tool_window_manager.py    GNU General Public License v3.0 6 votes vote down vote up
def select_widgets(self,
                       widget_type:         typing.Type[_WidgetTypeVar] = QWidget,
                       current_location:    typing.Optional[ToolWindowLocation] = None) -> typing.List[_WidgetTypeVar]:
        """
        Returns a list of references to the root widgets of all existing tool windows which are instances of the
        specified type. This can be used to broadcast events and such.
        Specify the type as QWidget to accept all widgets.
        """
        out: typing.List[_WidgetTypeVar] = []
        for win in self._children:
            if not isinstance(win.widget, widget_type):
                continue

            if current_location is not None:
                if self._parent_window.dockWidgetArea(win) != int(current_location):
                    continue

            out.append(win.widget)

        return out 
Example 5
Project: kucher   Author: Zubax   File: active_alerts_widget.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent: QWidget):
        super(ActiveAlertsWidget, self).__init__(parent, 'Active alerts', _ICON_OK)

        self._content = QLabel()
        self._content.setWordWrap(True)
        self._content.setAlignment(Qt.AlignCenter)

        font = QFont()
        font.setBold(True)
        font.setPointSize(round(font.pointSize() * 0.8))
        self._content.setFont(font)

        layout = QVBoxLayout()
        layout.addStretch(1)
        layout.addWidget(self._content)
        layout.addStretch(1)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self.reset() 
Example 6
Project: kucher   Author: Zubax   File: hardware_flag_counters_widget.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent: QWidget):
        super(HardwareFlagCountersWidget, self).__init__(parent,
                                                         'HW flag cnt.',
                                                         'integrated-circuit',
                                                         with_comments=True)
        self.setToolTip('Hardware flag counters - how many times each flag was seen')
        self.setStatusTip(self.toolTip())
        placeholder = '0'

        self._lvps_malfunction = self.create_value_display('LVPS mlf.',
                                                           placeholder,
                                                           tooltip='Low-voltage power supply malfunction')

        self._overload = self.create_value_display('Overload',
                                                   placeholder,
                                                   tooltip='Critical hardware overload or critical overheating')

        self._fault = self.create_value_display('Fault',
                                                placeholder,
                                                tooltip='Hardware fault flag') 
Example 7
Project: kucher   Author: Zubax   File: __init__.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent: QWidget):
        super(TaskSpecificStatusWidget, self).__init__(parent, _DEFAULT_TITLE, _DEFAULT_ICON)

        self._placeholder_widget = PlaceholderWidget(self)

        self._layout = QStackedLayout()
        self._layout.addWidget(self._placeholder_widget)

        self._task_id_to_widget_mapping: typing.Dict[TaskID, StatusWidgetBase] = {}
        for tid in TaskID:
            try:
                w = _TASK_ID_TO_WIDGET_TYPE_MAPPING[tid](self)
            except KeyError:
                self._task_id_to_widget_mapping[tid] = self._placeholder_widget
            else:
                self._task_id_to_widget_mapping[tid] = w
                self._layout.addWidget(w)

        _logger.info('Task ID to widget mapping: %r', self._task_id_to_widget_mapping)

        self._layout.setCurrentWidget(self._placeholder_widget)
        self.setLayout(self._layout) 
Example 8
Project: kucher   Author: Zubax   File: __init__.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                 parent:    QWidget,
                 commander: Commander):
        super(LowLevelManipulationControlWidget, self).__init__(parent)

        self._last_seen_timestamped_general_status: typing.Optional[typing.Tuple[float, GeneralStatusView]] = None

        self._tabs = QTabWidget(self)

        for widget_type in _LLM_MODE_TO_WIDGET_TYPE_MAPPING.values():
            widget = widget_type(self, commander)
            tab_name, icon_name = widget.get_widget_name_and_icon_name()
            self._tabs.addTab(widget, get_icon(icon_name), tab_name)

        self._current_widget: LowLevelManipulationControlSubWidgetBase = self._tabs.currentWidget()
        self._tabs.currentChanged.connect(self._on_current_widget_changed)

        # Presentation configuration.
        # We have only one widget here, so we reduce the margins to the bare minimum in order to
        # conserve the valuable screen space.
        # We also change the default appearance of the tab widget to make it look okay with the small margins.
        self._tabs.setTabPosition(QTabWidget.South)
        self._tabs.setDocumentMode(True)
        self.setLayout(lay_out_vertically((self._tabs, 1)))
        self.layout().setContentsMargins(0, 0, 0, 0) 
Example 9
Project: kucher   Author: Zubax   File: calibration_widget.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                 parent:            QWidget,
                 commander:         Commander):
        super(Widget, self).__init__(parent)
        self._commander = commander
        self.setLayout(
            lay_out_vertically(
                lay_out_horizontally(
                    QLabel('Calibrate the VSI hardware', self),
                    make_button(self,
                                text='Calibrate',
                                icon_name='scales',
                                on_clicked=self._execute),
                    (None, 1)
                ),
                (None, 1)
            )
        ) 
Example 10
Project: kucher   Author: Zubax   File: hardware_test_control_widget.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                 parent:    QWidget,
                 commander: Commander):
        super(HardwareTestControlWidget, self).__init__(parent)

        self._commander = commander

        self.setLayout(
            lay_out_vertically(
                QLabel('The motor must be connected in order for the self test to succeed.', self),
                lay_out_horizontally(
                    (None, 1),
                    make_button(self, text='Run self-test', icon_name='play', on_clicked=self._execute),
                    (None, 1),
                ),
                (None, 1),
            )
        ) 
Example 11
Project: kucher   Author: Zubax   File: main_widget.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                 parent:                    QWidget,
                 on_connection_request:     ConnectionRequestCallback,
                 on_disconnection_request:  DisconnectionRequestCallback,
                 commander:                 Commander):
        super(MainWidget, self).__init__(parent)

        self._resize_event = Event()

        self._device_management_widget =\
            DeviceManagementWidget(self,
                                   on_connection_request=on_connection_request,
                                   on_disconnection_request=on_disconnection_request)

        self._telega_control_widget = TelegaControlWidget(self, commander)

        self.addTab(self._device_management_widget, get_icon('connector'), 'Device management')
        self.addTab(self._telega_control_widget, get_icon('wagon'), 'Telega control panel')

        self.setCurrentWidget(self._device_management_widget) 
Example 12
Project: kucher   Author: Zubax   File: __init__.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent: QWidget):
        super(LogWidget, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)                  # This is required to stop background timers!

        self._clear_button = make_button(self, 'Clear', 'delete-document', on_clicked=self._do_clear)
        self._status_display = QLabel(self)

        self._model = _TableModel(self)
        self._model.layoutChanged.connect(self._on_model_changed)

        self._table_view = _TableView(self, self._model)

        # View setup
        controls_layout = QHBoxLayout()
        controls_layout.addWidget(self._clear_button)
        controls_layout.addStretch(1)
        controls_layout.addWidget(self._status_display)

        layout = QVBoxLayout()
        layout.addLayout(controls_layout)
        layout.addWidget(self._table_view, 1)
        self.setLayout(layout) 
Example 13
Project: kucher   Author: Zubax   File: spinbox_linked_with_slider.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                 parent:                QWidget,
                 minimum:               float = 0.0,
                 maximum:               float = 100.0,
                 step:                  float = 1.0,
                 slider_orientation:    SliderOrientation = SliderOrientation.VERTICAL):
        self._events_suppression_depth = 0

        # Instantiating the widgets
        self._box = QDoubleSpinBox(parent)
        self._sld = QSlider(int(slider_orientation), parent)

        self._sld.setTickPosition(QSlider.TicksBothSides)       # Perhaps expose this via API later

        # This stuff breaks if I remove lambdas, no clue why, investigate later
        self._box.valueChanged[float].connect(lambda v: self._on_box_changed(v))
        self._sld.valueChanged.connect(lambda v: self._on_sld_changed(v))

        # Initializing the parameters
        with self._with_events_suppressed():
            self.set_range(minimum, maximum)
            self.step = step

        # Initializing the API
        self._value_change_event = Event() 
Example 14
Project: MovieHeavens   Author: lt94   File: movies.py    GNU General Public License v2.0 6 votes vote down vote up
def init_layout(self):
        top_layout = QGridLayout()
        top_layout.addWidget(self.movie_name_label, 0, 0)
        top_layout.addWidget(self.movie_name_line_edit, 0, 1)
        top_layout.addWidget(self.movie_source_label, 0, 2)
        top_layout.addWidget(self.movie_source_combobox, 0, 3)
        top_layout.addWidget(self.search_push_button, 0, 4)
        top_layout.addWidget(self.tip_label, 3, 1)
        top_layout.addWidget(self.search_content_label, 3, 0)
        top_layout.addWidget(self.search_content_text_list, 4, 0, 2, 5)

        main_frame = QWidget()
        self.setCentralWidget(main_frame)
        main_frame.setLayout(top_layout)

        self.reward_window = ImageWindow('resources/wechat_reward.jpg', '赞赏')
        self.watch_window = ImageWindow('resources/watch_wechat.jpg', '关注')

        return self 
Example 15
Project: Python-GUI   Author: arpitj07   File: scorewidnow.py    MIT License 6 votes vote down vote up
def setupUi(self, ScoreWindow):
        ScoreWindow.setObjectName("ScoreWindow")
        ScoreWindow.resize(471, 386)
        self.centralwidget = QtWidgets.QWidget(ScoreWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.Score = QtWidgets.QLineEdit(self.centralwidget)
        self.Score.setGeometry(QtCore.QRect(180, 180, 113, 22))
        self.Score.setObjectName("Score")
        self.teamscore = QtWidgets.QLabel(self.centralwidget)
        self.teamscore.setGeometry(QtCore.QRect(180, 130, 151, 20))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.teamscore.setFont(font)
        self.teamscore.setObjectName("teamscore")
        ScoreWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(ScoreWindow)
        self.statusbar.setObjectName("statusbar")
        ScoreWindow.setStatusBar(self.statusbar)

        self.retranslateUi(ScoreWindow)
        QtCore.QMetaObject.connectSlotsByName(ScoreWindow) 
Example 16
Project: Physics_Project   Author: QuandisS   File: credits_form.py    Apache License 2.0 5 votes vote down vote up
def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(400, 300)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.gridLayoutWidget.setGeometry(QtCore.QRect(-1, -1, 801, 561))
        self.gridLayoutWidget.setObjectName("gridLayoutWidget")
        self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.textBrowser = QtWidgets.QTextBrowser(self.gridLayoutWidget)
        self.textBrowser.setOpenExternalLinks(True)
        self.textBrowser.setObjectName("textBrowser")
        self.gridLayout.addWidget(self.textBrowser, 1, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.centralwidget.setLayout(self.gridLayout)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow) 
Example 17
Project: ILTIS   Author: grg2rsr   File: MainWindow_Widget.py    GNU General Public License v2.0 5 votes vote down vote up
def init_UI(self):
        """ """
        # own layout
#        DesktopWidget = QtGui.QDesktopWidget()
#        qrect = DesktopWidget.screenGeometry()
#        height, width = qrect.height(), qrect.width()

#        self.resize(width*0.7,height*0.7)
#        self.move(width/15,height/15)
        self.showMaximized()

        # ini
        self.Data_Display = Data_Display_Widget(self.Main,self)
        self.Front_Control_Panel = Front_Control_Panel_Widget(self.Main,self)
        self.Container = QtWidgets.QWidget()
        self.Options_Control = Options_Control_Widget(self.Main,self)
#
#        # splitter variant
        self.Splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
        self.Splitter.addWidget(self.Data_Display)
        self.Splitter.addWidget(self.Front_Control_Panel)

#        self.Splitter = QtGui.QWidget(self)
        self.setCentralWidget(self.Splitter)

#        self.setWindowIcon(QtGui.QIcon(self.Main.graphics_path + os.path.sep + )) ### FIXME
        self.setWindowTitle('ILTIS')

        frac = 0.8
        self.Splitter.setSizes([int(self.Splitter.size().height() * frac), int(self.Splitter.size().height() * (1-frac))])
        # note: http://stackoverflow.com/questions/16280323/qt-set-size-of-qmainwindow

        self.show()

        pass 
Example 18
Project: ILTIS   Author: grg2rsr   File: Traces_Visualizer_Stimsorted_Widget.py    GNU General Public License v2.0 5 votes vote down vote up
def init_data(self):
        self.reset()

        # some preparations
        self.trial_labels = self.Main.Data.Metadata.trial_labels
        self.trial_indices = list(range(self.Main.Data.nTrials))
        self.trial_labels_unique = sp.unique(self.trial_labels)
        self.nStimClasses = len(self.trial_labels_unique)
        self.nRepetitions = self.trial_labels.count(self.trial_labels[0]) # FIXME: this imposes a fixed number of repetitions per trial. this should be changed into a vector holding values for each stim

        # generating the UI
        # looping over StimClasses
        for i, StimClass in enumerate(range(self.nStimClasses)):
            if self.Main.Options.view['trial_labels_on_traces_vis']:
                print(self.Main.Options.view['trial_labels_on_traces_vis'])
                plot = self.plotWidget.addPlot(title=self.trial_labels_unique[StimClass])
            else:
                plot = self.plotWidget.addPlot(title=None) # for inheriting from QWidget
            plot.setLabel('left', 'F')
            plot.setLabel('bottom', 'frame #')
            plot.showGrid(x=True, y=True, alpha=0.5)

            # link for common axes
            if i != 0:
                plot.setYLink(self.plotItems[0])
                plot.setXLink(self.plotItems[0])

            # vlines
            vline = plot.addLine(x=self.Data_Display.Frame_Visualizer.frame, movable=True)
            vline.setBounds((0, self.Main.Data.nFrames -1))
            self.vlines.append(vline)

            # add the plot to the list of plots
            self.plotItems.append(plot)

        # set the layout
        self.update_stim_regions()
        self.Layout.addWidget(self.plotWidget) 
Example 19
Project: ILTIS   Author: grg2rsr   File: Options_Control_Widget.py    GNU General Public License v2.0 5 votes vote down vote up
def make_tab(self,tab_label):
        """ helper: makes a tab page, pace QFormLayout inside and return it """
        tab_widget = QtWidgets.QWidget(self)
        self.addTab(tab_widget,tab_label)
        FormLayout = QtWidgets.QFormLayout(tab_widget)
        FormLayout.setVerticalSpacing(10)
        FormLayout.setLabelAlignment(QtCore.Qt.AlignRight)
        tab_widget.setLayout(FormLayout)
        return FormLayout 
Example 20
Project: pywerami   Author: ondrolexa   File: mainapp.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        super(OptionsForm, self).__init__(parent)
        settings = QtCore.QSettings("LX", "pywerami")
        layout = QtWidgets.QVBoxLayout(self)
        form = QtWidgets.QWidget()
        formlayout = QtWidgets.QFormLayout(form)

        ## scale
        #self.scale = QLineEdit(repr(settings.value("scale", 1, type=float)), self)
        #self.scale.setValidator(QDoubleValidator(self.scale))
        #formlayout.addRow('Scale', self.scale)

        # not-a-number
        self.nan = QtWidgets.QLineEdit(settings.value("nan", "NaN", type=str), self)
        formlayout.addRow('Not a number', self.nan)

        form.setLayout(formlayout)
        buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
        layout.addWidget(form)
        layout.addWidget(buttonBox)
        self.setLayout(layout)

        buttonBox.accepted.connect(self.check)
        buttonBox.rejected.connect(self.reject)

        self.setWindowTitle("PyWerami options") 
Example 21
Project: idasec   Author: RobinDavid   File: StandardResultWidget.py    GNU Lesser General Public License v2.1 5 votes vote down vote up
def __init__(self, parent):
        QtWidgets.QWidget.__init__(self)
        self.setupUi(self)
        self.parent = parent
        self.action_selector.setEnabled(False)
        self.action_button.setEnabled(False)
        for k in self.parent.actions.keys():

            self.action_selector.addItem(k)
        self.action_button.clicked.connect(self.action_clicked)
        self.action_selector.currentIndexChanged[str].connect(self.action_selector_changed) 
Example 22
Project: pyqimageview   Author: nevion   File: viewer.py    MIT License 5 votes vote down vote up
def __init__(self, image, input_path):
        QMainWindow.__init__(self)
        self.image = image
        self.input_path = input_path
        self.image_view = AppImageView(self)
        self.image_view.main_widget = self
        self.statusBar().showMessage("")

        #self.resize(image.size())
        padding = self.frameGeometry().size() - self.geometry().size()
        self.resize(image.size() + padding)
        #self.resize(797, 615)

        central = QWidget(self)
        central.setObjectName("MainWindow")

        self.verticalLayout = QtWidgets.QVBoxLayout(central)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        #self.verticalLayout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
        self.verticalLayout.setObjectName("verticalLayout")
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(self.image_view.sizePolicy().hasHeightForWidth())
        self.image_view.setSizePolicy(sizePolicy)
        self.image_view.setMouseTracking(True)
        self.image_view.setFocusPolicy(QtCore.Qt.NoFocus)
        self.image_view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.image_view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.image_view.setObjectName("image_view")
        self.verticalLayout.addWidget(self.image_view)

        self.setCentralWidget(central)
        self.layout().setContentsMargins(0, 0, 0, 0)

        screen = QDesktopWidget().screenGeometry(self)
        size = self.geometry()
        self.move((screen.width()-size.width())/4, (screen.height()-size.height())/4)

        self.update_view()
        self.image_view.reset() 
Example 23
Project: kucher   Author: Zubax   File: tool_window_manager.py    GNU General Public License v3.0 5 votes vote down vote up
def add_arrangement_rule(self,
                             apply_to:      typing.Iterable[typing.Type[QWidget]],
                             group_when:    ToolWindowGroupingCondition,
                             location:      ToolWindowLocation):
        """
        :param apply_to:
        :param group_when:  Grouping policy:
                                NEVER         - do not group unless the user did that manually
                                SAME_LOCATION - group only if the grouped widgets are at the same location
                                ALWAYS        - group always, regardless of the location
        :param location:    Default placement in the main window
        """
        self._arrangement_rules.append(_ArrangementRule(apply_to=list(apply_to),
                                                        group_when=group_when,
                                                        location=location)) 
Example 24
Project: kucher   Author: Zubax   File: tool_window_manager.py    GNU General Public License v3.0 5 votes vote down vote up
def _select_tool_windows(self, widget_type: typing.Type[QWidget]) -> typing.List[ToolWindow]:
        return [win for win in self._children if isinstance(win.widget, widget_type)] 
Example 25
Project: kucher   Author: Zubax   File: tool_window_manager.py    GNU General Public License v3.0 5 votes vote down vote up
def _select_applicable_arrangement_rules(self, widget_type: typing.Type[QWidget]) -> \
            typing.List['_ArrangementRule']:
        return [copy.deepcopy(ar) for ar in self._arrangement_rules if widget_type in ar.apply_to] 
Example 26
Project: kucher   Author: Zubax   File: little_bobby_tables_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(LittleBobbyTablesWidget, self).__init__(parent)

        self._table = QTableWidget(self)
        self._table.setColumnCount(1)
        self._table.horizontalHeader().hide()
        self._table.setFont(get_monospace_font())
        self._table.horizontalHeader().setSectionResizeMode(self._table.horizontalHeader().ResizeToContents)
        self._table.horizontalHeader().setStretchLastSection(True)
        self._table.verticalHeader().setSectionResizeMode(self._table.verticalHeader().ResizeToContents)

        lay_on_macduff = QVBoxLayout()
        lay_on_macduff.addWidget(self._table)
        lay_on_macduff.setContentsMargins(0, 0, 0, 0)
        self.setLayout(lay_on_macduff) 
Example 27
Project: kucher   Author: Zubax   File: __init__.py    GNU General Public License v3.0 5 votes vote down vote up
def _configure_tool_windows(self,
                                on_task_statistics_request: TaskStatisticsRequestCallback):
        self._tool_window_manager.add_arrangement_rule(apply_to=[LogWidget, TaskStatisticsWidget],
                                                       group_when=ToolWindowGroupingCondition.ALWAYS,
                                                       location=ToolWindowLocation.BOTTOM)

        self._tool_window_manager.add_arrangement_rule(apply_to=[RegisterViewWidget],
                                                       group_when=ToolWindowGroupingCondition.ALWAYS,
                                                       location=ToolWindowLocation.RIGHT)

        self._tool_window_manager.register(lambda parent: TaskStatisticsWidget(parent, on_task_statistics_request),
                                           'Task statistics',
                                           'spreadsheet',
                                           shown_by_default=not is_small_screen())

        self._tool_window_manager.register(LogWidget,
                                           'Device log',
                                           'log',
                                           shown_by_default=True)

        def spawn_register_widget(parent: QWidget):
            w = RegisterViewWidget(parent)
            if self._registers is not None:
                w.setup(self._registers)

            return w

        self._tool_window_manager.register(spawn_register_widget,
                                           'Registers',
                                           'data',
                                           shown_by_default=True)

    # noinspection PyCallByClass,PyUnresolvedReferences,PyArgumentList 
Example 28
Project: kucher   Author: Zubax   File: __init__.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(_TableModel, self).__init__(parent)

        self._data: TaskStatisticsView = TaskStatisticsView()

        self._icon_size = QFontMetrics(QFont()).height() 
Example 29
Project: kucher   Author: Zubax   File: __init__.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 parent:    QWidget,
                 commander: Commander):
        super(TelegaControlWidget, self).__init__(parent)

        self._dc_quantities_widget = DCQuantitiesWidget(self)
        self._temperature_widget = TemperatureWidget(self)
        self._hardware_flag_counters_widget = HardwareFlagCountersWidget(self)
        self._device_status_widget = DeviceStatusWidget(self)
        self._vsi_status_widget = VSIStatusWidget(self)
        self._active_alerts_widget = ActiveAlertsWidget(self)

        self._task_specific_status_widget = TaskSpecificStatusWidget(self)

        self._control_widget = ControlWidget(self, commander)

        self.setLayout(
            lay_out_vertically(
                lay_out_horizontally(
                    (self._dc_quantities_widget, 1),
                    (self._temperature_widget, 1),
                    (self._hardware_flag_counters_widget, 1),
                    (self._vsi_status_widget, 1),
                    (self._active_alerts_widget, 2),
                ),
                lay_out_horizontally(
                    (self._device_status_widget, 1),
                    (self._task_specific_status_widget, 5),
                ),
                self._control_widget,
            ),
        ) 
Example 30
Project: kucher   Author: Zubax   File: device_status_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(DeviceStatusWidget, self).__init__(parent, 'Device status', 'question-mark')
        self.setToolTip('Use the Task Statistics view for more information')

        self._task_display = self.create_value_display('Current task', 'N/A')

        self._monotonic_time_display = self.create_value_display('Mono clock', 'N/A',
                                                                 'Steady monotonic clock measuring time since boot')

        self.create_value_display('')   # Reserved/placeholder, needed for better alignment
        self.create_value_display('')   # Reserved/placeholder, needed for better alignment 
Example 31
Project: kucher   Author: Zubax   File: placeholder_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(PlaceholderWidget, self).__init__(parent)

        label = QLabel(self)
        label.setText('Task-specific status information is not available')
        label.setWordWrap(True)
        label.setAlignment(Qt.AlignCenter)

        font: QFont = label.font()
        font.setItalic(True)
        label.setFont(font)

        layout = QVBoxLayout()
        layout.addWidget(label)
        self.setLayout(layout) 
Example 32
Project: kucher   Author: Zubax   File: motor_identification_status_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(Widget, self).__init__(parent)

        self._progress_bar = QProgressBar(self)
        self._progress_bar.setMinimum(0)
        self._progress_bar.setMaximum(100)

        self.setLayout(
            lay_out_vertically(self._progress_bar)
        ) 
Example 33
Project: kucher   Author: Zubax   File: base.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(StatusWidgetBase, self).__init__(parent) 
Example 34
Project: kucher   Author: Zubax   File: run_status_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(_DQDisplayWidget, self).__init__(parent)

        def make_label(text: str = '') -> QLabel:
            w = QLabel(text, self)
            w.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
            font = QFont()
            font.setBold(True)
            w.setFont(font)
            return w

        self._ud = make_label()
        self._uq = make_label()
        self._id = make_label()
        self._iq = make_label()

        self._ud.setToolTip('Direct axis voltage')
        self._uq.setToolTip('Quadrature axis voltage')
        self._id.setToolTip('Direct axis current')
        self._iq.setToolTip('Quadrature axis current')

        # 0  1  2
        # 1 Ud Uq
        # 2 Id Iq
        layout = QGridLayout(self)
        layout.addWidget(QLabel('U<sub>DQ</sub>', self), 0, 0)
        layout.addWidget(QLabel('I<sub>DQ</sub>', self), 1, 0)
        layout.addWidget(self._ud, 0, 1)
        layout.addWidget(self._uq, 0, 2)
        layout.addWidget(self._id, 1, 1)
        layout.addWidget(self._iq, 1, 2)
        layout.addWidget(make_label('V'), 0, 3)
        layout.addWidget(make_label('A'), 1, 3)
        layout.setColumnStretch(0, 4)
        layout.setColumnStretch(1, 2)
        layout.setColumnStretch(2, 2)
        layout.setColumnStretch(3, 1)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout) 
Example 35
Project: kucher   Author: Zubax   File: run_status_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def _make_vertical_separator(parent: QWidget) -> QWidget:
    # https://stackoverflow.com/questions/10053839/how-does-designer-create-a-line-widget
    line = QFrame(parent)
    line.setFrameShape(QFrame.VLine)
    line.setStyleSheet('QFrame { color: palette(mid); };')
    line.setMinimumWidth(QFontMetrics(QFont()).width('__') * 2)
    return line 
Example 36
Project: kucher   Author: Zubax   File: hardware_test_status_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(Widget, self).__init__(parent)

        self._progress_bar = QProgressBar(self)
        self._progress_bar.setMinimum(0)
        self._progress_bar.setMaximum(100)

        self.setLayout(
            lay_out_vertically(self._progress_bar)
        ) 
Example 37
Project: kucher   Author: Zubax   File: dc_quantities_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(DCQuantitiesWidget, self).__init__(parent,
                                                 'DC quantities',
                                                 'electricity',
                                                 with_comments=True)
        dp = MonitoredQuantityPresenter.DisplayParameters
        style = ValueDisplayWidget.Style
        placeholder = 'N/A'

        self._voltage = MonitoredQuantityPresenter(self.create_value_display('Voltage', placeholder),
                                                   '%.1f V',
                                                   params_default=dp(comment='OK',
                                                                     icon_name='ok'),
                                                   params_when_low=dp(comment='Undervoltage',
                                                                      icon_name='overload-negative',
                                                                      style=style.ALERT_LOW),
                                                   params_when_high=dp(comment='Overvoltage',
                                                                       icon_name='overload',
                                                                       style=style.ALERT_HIGH))

        self._current = MonitoredQuantityPresenter(self.create_value_display('Current', placeholder),
                                                   '%.1f A',
                                                   params_default=dp(comment='OK',
                                                                     icon_name='ok'),
                                                   params_when_low=dp(comment='Recuperation overcurrent',
                                                                      icon_name='overload-negative',
                                                                      style=style.ALERT_LOW),
                                                   params_when_high=dp(comment='Overcurrent',
                                                                       icon_name='overload',
                                                                       style=style.ALERT_HIGH))

        self._power = MonitoredQuantityPresenter(self.create_value_display('Power', placeholder),
                                                 '%.0f W') 
Example 38
Project: kucher   Author: Zubax   File: base.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(LowLevelManipulationControlSubWidgetBase, self).__init__(parent) 
Example 39
Project: kucher   Author: Zubax   File: motor_identification_control_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 parent:    QWidget,
                 commander: Commander):
        super(MotorIdentificationControlWidget, self).__init__(parent)

        self._commander = commander

        self._mode_map = {
            _humanize(mid): mid for mid in MotorIdentificationMode
        }

        self._mode_selector = QComboBox(self)
        self._mode_selector.setEditable(False)
        # noinspection PyTypeChecker
        self._mode_selector.addItems(map(_humanize,
                                         sorted(MotorIdentificationMode,
                                                key=lambda x: x != MotorIdentificationMode.R_L_PHI)))

        go_button = QPushButton(get_icon('play'), 'Launch', self)
        go_button.clicked.connect(self._execute)

        self.setLayout(
            lay_out_vertically(
                lay_out_horizontally(
                    QLabel('Select parameters to estimate:', self),
                    self._mode_selector,
                    (None, 1),
                ),
                lay_out_horizontally(
                    QLabel('Then click', self),
                    go_button,
                    QLabel('and wait. The process will take a few minutes to complete.', self),
                    (None, 1),
                ),
                (None, 1)
            )
        ) 
Example 40
Project: kucher   Author: Zubax   File: __init__.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: typing.Optional[QWidget]):
        super(WidgetBase, self).__init__(parent) 
Example 41
Project: kucher   Author: Zubax   File: value_display_group_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 parent:        QWidget,
                 title:         str,
                 icon_name:     typing.Optional[str] = None,
                 with_comments: bool = False):
        super(ValueDisplayGroupWidget, self).__init__(parent, title, icon_name)

        self._with_comments = with_comments
        self._inferiors: typing.List[ValueDisplayWidget] = []
        self._inferior_layout = QVBoxLayout()
        self.setLayout(self._inferior_layout)

    # noinspection PyArgumentList 
Example 42
Project: kucher   Author: Zubax   File: group_box_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 parent:        QWidget,
                 title:         str,
                 icon_name:     typing.Optional[str] = None):
        super(GroupBoxWidget, self).__init__(title, parent)

        # Changing icons is very expensive, so we store last set icon in order to avoid re-setting it
        self._current_icon: typing.Optional[str] = None

        if icon_name:
            self.set_icon(icon_name) 
Example 43
Project: kucher   Author: Zubax   File: spinbox_linked_with_slider.py    GNU General Public License v3.0 5 votes vote down vote up
def slider(self) -> QWidget:
        """
        Annotated as QWidget in order to prevent direct access to the critical functionality of the widgets,
        as that may break the inner logic of the class. This property should only be used for layout purposes.
        """
        return self._sld 
Example 44
Project: kucher   Author: Zubax   File: spinbox_linked_with_slider.py    GNU General Public License v3.0 5 votes vote down vote up
def _unittest_spinbox_linked_with_slider():
    import time
    from PyQt5.QtWidgets import QApplication, QMainWindow, QLayout
    from kucher.view.utils import lay_out_horizontally, lay_out_vertically

    app = QApplication([])

    instances: typing.List[SpinboxLinkedWithSlider] = []

    def make(minimum:   float,
             maximum:   float,
             step:      float) -> QLayout:
        o = SpinboxLinkedWithSlider(widget,
                                    minimum=minimum,
                                    maximum=maximum,
                                    step=step,
                                    slider_orientation=SpinboxLinkedWithSlider.SliderOrientation.HORIZONTAL)
        instances.append(o)
        return lay_out_horizontally((o.slider, 1), o.spinbox)

    win = QMainWindow()
    widget = QWidget(win)
    widget.setLayout(lay_out_vertically(make(0, 100, 1),
                                        make(-10, 10, 0.01),
                                        make(-99999, 100, 100)))
    win.setCentralWidget(widget)
    win.show()

    def run_a_bit():
        for _ in range(1000):
            time.sleep(0.005)
            app.processEvents()

    run_a_bit()
    instances[0].minimum = -1000
    instances[2].step = 10
    run_a_bit()

    win.close() 
Example 45
Project: kucher   Author: Zubax   File: value_display_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 parent: QWidget,
                 title: str,
                 placeholder_text: typing.Optional[str] = None,
                 with_comment: bool = False,
                 tooltip: typing.Optional[str] = None):
        super(ValueDisplayWidget, self).__init__(parent)

        self._placeholder_text = str(placeholder_text or '')

        self._value_display = QLabel(self)
        self._value_display.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
        bold_font = QFont()
        bold_font.setBold(True)
        self._value_display.setFont(bold_font)

        if with_comment:
            self._comment = _Comment(self)
        else:
            self._comment = None

        self._default_tooltip = str(tooltip or '')
        self.setToolTip(self._default_tooltip)
        self.setStatusTip(self.toolTip())

        title_label = QLabel(title)
        title_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)

        layout = QHBoxLayout()
        layout.addWidget(title_label, 1)
        layout.addWidget(self._value_display, 1)
        if self._comment is not None:
            layout.addWidget(self._comment)

        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
        self.reset() 
Example 46
Project: kucher   Author: Zubax   File: value_display_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(_Comment, self).__init__(parent)
        self.setAlignment(Qt.AlignCenter)
        self._icon_size = QFontMetrics(QFont()).height()        # As large as font
        self._pixmap_cache: typing.Dict[str, QPixmap] = {}
        self._current_icon_name: typing.Optional[str] = None
        # Initializing defaults
        self.reset() 
Example 47
Project: kucher   Author: Zubax   File: tool_window.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 parent:            QWidget,
                 title:             typing.Optional[str] = None,
                 icon_name:         typing.Optional[str] = None):
        super(QDockWidget, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)                  # This is required to stop background timers!

        if title:
            self.setWindowTitle(title)

        if icon_name:
            self.set_icon(icon_name)

        self._close_event = Event()
        self._resize_event = Event() 
Example 48
Project: kucher   Author: Zubax   File: tool_window.py    GNU General Public License v3.0 5 votes vote down vote up
def widget(self, widget: QWidget):
        if not isinstance(widget, QWidget):
            raise TypeError(f'Expected QWidget, got {type(widget)}')

        self.setWidget(widget)

    # noinspection PyCallingNonCallable,PyArgumentList 
Example 49
Project: MovieHeavens   Author: lt94   File: movies.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, resources, title):
        super(ImageWindow, self).__init__()
        self.setWindowTitle(title)

        self.central_widget = QWidget()
        self.setCentralWidget(self.central_widget)
        layout = QVBoxLayout(self.central_widget)

        image = QImage(resources)
        pixmap = QPixmap(resources)
        image_label = QLabel(self)
        image_label.setPixmap(pixmap)
        image_label.resize(pixmap.width(), pixmap.height())
        layout.addWidget(image_label) 
Example 50
Project: rainbow6-siege-danmu-request   Author: fy-meng   File: gui.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, font, font_size, font_color, bg_color):
        super().__init__()
        self.setGeometry(300, 300, 200, 400)
        self.setWindowTitle('Display')
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
        self.setStyleSheet('QWidget {background-color: ' + bg_color + '}')

        text = 'ATTACKERS:\n' \
               '    BLACKBEARD\n' \
               '    --\n' \
               '    --\n' \
               'DEFENDERS:\n' \
               '    --\n' \
               '    --\n' \
               '    --'
        self._label = QLabel(text, self)
        self._label.setFont(QFont(font, font_size, QFont.Bold))
        self._label.setStyleSheet('QLabel { color: ' + font_color + ';}')

        self._offset = None

        self.show()

        text = 'ATTACKERS:\n' \
               '    --\n' \
               '    --\n' \
               '    --\n' \
               'DEFENDERS:\n' \
               '    --\n' \
               '    --\n' \
               '    --'

        self._label.setText(text)