class PandaPrimitiveWidget(QFrame): # static variables status_label_dict = { pp.PandaPrimitiveStatus.NEUTRAL: '', pp.PandaPrimitiveStatus.READY: pp.PandaPrimitiveStatus.READY.name, pp.PandaPrimitiveStatus.ERROR: pp.PandaPrimitiveStatus.ERROR.name, pp.PandaPrimitiveStatus.EXECUTING: pp.PandaPrimitiveStatus.EXECUTING.name, pp.PandaPrimitiveStatus.REVERTING: pp.PandaPrimitiveStatus.REVERTING.name, pp.PandaPrimitiveStatus.EXECUTED: '' } font = QFont() font.setBold(True) font.setPointSize(10) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) def __init__(self, parent, panda_primitive): super(PandaPrimitiveWidget, self).__init__(parent) self.initUI(panda_primitive) def initUI(self, panda_primitive): # Create widget subcomponents self.primitive = panda_primitive self.primitive_label = QLabel() self.status_label = QLabel( str(PandaPrimitiveWidget.status_label_dict[ panda_primitive.status])) self.status_label.setAlignment(Qt.AlignCenter) # Fetch fitting icon for primitive primitive_icon_path = os.path.join( rospkg.RosPack().get_path('panda_pbd'), 'resources', panda_primitive.__class__.__name__ + '.png') primitive_image = QPixmap(primitive_icon_path) self.primitive_label.setPixmap(primitive_image) # Add vertical layout layout = QVBoxLayout(self) layout.addWidget(self.primitive_label) layout.addWidget(self.status_label) self.setSizePolicy(PandaPrimitiveWidget.sizePolicy) # Beautify QFrame and Color self.setFrameShape(QFrame.Panel) self.setFrameShadow(QFrame.Raised) self.setLineWidth(2) self.status_label.setFont(PandaPrimitiveWidget.font) # Animation self.animation = QPropertyAnimation(self, 'background_color') self.animation.setDuration(2000) # in ms self.animation.setLoopCount(-1) self.animation.setStartValue(QColor('ghostwhite')) self.animation.setEndValue(QColor('ghostwhite')) self.animation.setKeyValueAt(0.5, QColor('cornflowerblue')) self.setAutoFillBackground(True) self.setPalette(gray_palette) def get_background_color(self): return self.palette().color(QPalette.Background) def set_background_color(self, color): palette = QPalette() palette.setColor(QPalette.Background, color) self.setPalette(palette) background_color = pyqtProperty(QColor, get_background_color, set_background_color) def sizeHint(self): return QSize(PRIMITIVE_WIDTH, PRIMITIVE_HEIGHT) def updateWidget(self): if self.primitive.status == pp.PandaPrimitiveStatus.EXECUTING or \ self.primitive.status == pp.PandaPrimitiveStatus.REVERTING: self.animation.start() elif self.primitive.status == pp.PandaPrimitiveStatus.ERROR: self.animation.stop() self.setPalette(error_palette) else: self.animation.stop() if self.primitive.status == pp.PandaPrimitiveStatus.EXECUTED: self.setPalette(executed_primitive_palette) elif self.primitive.status == pp.PandaPrimitiveStatus.READY: self.setPalette(white_palette) else: self.setPalette(gray_palette) self.status_label.setText( str(PandaPrimitiveWidget.status_label_dict[self.primitive.status])) self.update()
def __init__(self, parent): QLineEdit.__init__(self, parent) self.textChanged.connect(self._handleTextChanged) self.returnPressed.connect(self._handleReturnPressed) self.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
def __init__(self, parent=None, **kw): # the current button self._ActiveButton = Qt.NoButton # private attributes self.__saveX = 0 self.__saveY = 0 self.__saveModifiers = Qt.NoModifier self.__saveButtons = Qt.NoButton self.__wheelDelta = 0 # do special handling of some keywords: # stereo, rw try: stereo = bool(kw['stereo']) except KeyError: stereo = False try: rw = kw['rw'] except KeyError: rw = None # create base qt-level widget if QVTKRWIBase == "QWidget": if "wflags" in kw: wflags = kw['wflags'] else: wflags = Qt.WindowFlags() QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC) elif QVTKRWIBase == "QGLWidget": QGLWidget.__init__(self, parent) if rw: # user-supplied render window self._RenderWindow = rw else: self._RenderWindow = vtkRenderWindow() WId = self.winId() # Python2 if type(WId).__name__ == 'PyCObject': from ctypes import pythonapi, c_void_p, py_object pythonapi.PyCObject_AsVoidPtr.restype = c_void_p pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object] WId = pythonapi.PyCObject_AsVoidPtr(WId) # Python3 elif type(WId).__name__ == 'PyCapsule': from ctypes import pythonapi, c_void_p, py_object, c_char_p pythonapi.PyCapsule_GetName.restype = c_char_p pythonapi.PyCapsule_GetName.argtypes = [py_object] name = pythonapi.PyCapsule_GetName(WId) pythonapi.PyCapsule_GetPointer.restype = c_void_p pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p] WId = pythonapi.PyCapsule_GetPointer(WId, name) self._RenderWindow.SetWindowInfo(str(int(WId))) if stereo: # stereo mode self._RenderWindow.StereoCapableWindowOn() self._RenderWindow.SetStereoTypeToCrystalEyes() try: self._Iren = kw['iren'] except KeyError: self._Iren = vtkGenericRenderWindowInteractor() self._Iren.SetRenderWindow(self._RenderWindow) # do all the necessary qt setup self.setAttribute(Qt.WA_OpaquePaintEvent) self.setAttribute(Qt.WA_PaintOnScreen) self.setMouseTracking(True) # get all mouse events self.setFocusPolicy(Qt.WheelFocus) self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self._Timer = QTimer(self) self._Timer.timeout.connect(self.TimerEvent) self._Iren.AddObserver('CreateTimerEvent', self.CreateTimer) self._Iren.AddObserver('DestroyTimerEvent', self.DestroyTimer) self._Iren.GetRenderWindow().AddObserver('CursorChangedEvent', self.CursorChangedEvent) # If we've a parent, it does not close the child when closed. # Connect the parent's destroyed signal to this widget's close # slot for proper cleanup of VTK objects. if self.parent(): self.parent().destroyed.connect(self.close, Qt.DirectConnection)
def propertyInserted(self, index, afterIndex): afterItem = self.m_indexToItem[afterIndex] parentItem = self.m_indexToItem.value(index.parent()) newItem = WidgetItem() newItem.parent = parentItem layout = 0 parentWidget = 0 row = -1 if (not afterItem): row = 0 if (parentItem): parentItem.children.insert(0, newItem) else: self.m_children.insert(0, newItem) else: if (parentItem): row = parentItem.children.indexOf(afterItem) + 1 parentItem.children.insert(row, newItem) else: row = self.m_children.indexOf(afterItem) + 1 self.m_children.insert(row, newItem) if (parentItem and self.hasHeader(parentItem)): row += 2 if (not parentItem): layout = self.m_mainLayout parentWidget = self.q_ptr else: if not parentItem.groupBox: self.m_recreateQueue.removeAll(parentItem) par = parentItem.parent w = 0 l = 0 oldRow = -1 if (not par): w = self.q_ptr l = self.m_mainLayout oldRow = self.m_children.indexOf(parentItem) else: w = par.groupBox l = par.layout oldRow = par.children.indexOf(parentItem) if (self.hasHeader(par)): oldRow += 2 parentItem.groupBox = QGroupBox(w) parentItem.layout = QGridLayout() parentItem.groupBox.setLayout(parentItem.layout) if (parentItem.label): l.removeWidget(parentItem.label) parentItem.label.close() parentItem.label = 0 if (parentItem.widget): l.removeWidget(parentItem.widget) parentItem.widget.setParent(parentItem.groupBox) parentItem.layout.addWidget(parentItem.widget, 0, 0, 1, 2) parentItem.line = QFrame(parentItem.groupBox) elif (parentItem.widgetLabel): l.removeWidget(parentItem.widgetLabel) parentItem.widgetLabel.close() parentItem.widgetLabel = 0 if (parentItem.line): parentItem.line.setFrameShape(QFrame.HLine) parentItem.line.setFrameShadow(QFrame.Sunken) parentItem.layout.addWidget(parentItem.line, 1, 0, 1, 2) l.addWidget(parentItem.groupBox, oldRow, 0, 1, 2) self.updateItem(parentItem) layout = parentItem.layout parentWidget = parentItem.groupBox newItem.label = QLabel(parentWidget) newItem.label.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) newItem.widget = self.createEditor(index.property(), parentWidget) if (not newItem.widget): newItem.widgetLabel = QLabel(parentWidget) newItem.widgetLabel.setSizePolicy( QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed)) newItem.widgetLabel.setTextFormat(Qt.PlainText) else: newItem.widget.destroyed.connect(self.slotEditorDestroyed) self.m_widgetToItem[newItem.widget] = newItem self.insertRow(layout, row) span = 1 if (newItem.widget): layout.addWidget(newItem.widget, row, 1) elif (newItem.widgetLabel): layout.addWidget(newItem.widgetLabel, row, 1) else: span = 2 layout.addWidget(newItem.label, row, 0, 1, span) self.m_itemToIndex[newItem] = index self.m_indexToItem[index] = newItem self.updateItem(newItem)
def __init__(self, *args): super().__init__(BrickletIndustrialDual020mAV2, *args) self.dual020 = self.device self.str_connected = 'Channel {0} is <font color="green">connected (>= 3.9 mA)</font>' self.str_not_connected = 'Channel {0} is <font color="red">not connected (< 3.9 mA)</font>' self.cbe_current0 = CallbackEmulator( self, self.dual020.get_current, 0, self.cb_current, self.increase_error_count, pass_arguments_to_result_callback=True) self.cbe_current1 = CallbackEmulator( self, self.dual020.get_current, 1, self.cb_current, self.increase_error_count, pass_arguments_to_result_callback=True) self.connected_labels = [ FixedSizeLabel(self.str_not_connected.format(0)), FixedSizeLabel(self.str_not_connected.format(1)) ] self.current_current = [CurveValueWrapper(), CurveValueWrapper()] # float, mA plots = [('Channel 0', Qt.red, self.current_current[0], lambda value: '{:.03f} mA'.format(round(value, 3))), ('Channel 1', Qt.blue, self.current_current[1], lambda value: '{:.03f} mA'.format(round(value, 3)))] self.plot_widget = PlotWidget('Current [mA]', plots, extra_key_widgets=self.connected_labels, y_resolution=0.001) h_sp = QSizePolicy() h_sp.setHorizontalPolicy(QSizePolicy.Expanding) self.sample_rate_label = QLabel('Sample Rate:') self.sample_rate_combo = QComboBox() self.sample_rate_combo.addItem('240 Hz') self.sample_rate_combo.addItem('60 Hz') self.sample_rate_combo.addItem('15 Hz') self.sample_rate_combo.addItem('4 Hz') self.sample_rate_combo.currentIndexChanged.connect( self.sample_rate_combo_index_changed) self.sample_rate_combo.setSizePolicy(h_sp) self.gain_label = QLabel('Gain:') self.gain_combo = QComboBox() self.gain_combo.addItem('x1') self.gain_combo.addItem('x2') self.gain_combo.addItem('x4') self.gain_combo.addItem('x8') self.gain_combo.currentIndexChanged.connect( self.gain_combo_index_changed) self.gain_combo.setSizePolicy(h_sp) self.led_config_ch0_label = QLabel('Channel 0') self.led_config_ch1_label = QLabel('Channel 1') self.led_config_label = QLabel('LED Config:') self.led_status_config_label = QLabel('LED Status Config:') self.led_status_config_ch0_min_label = QLabel('Min:') self.led_status_config_ch0_max_label = QLabel('Max:') self.led_status_config_ch1_min_label = QLabel('Min:') self.led_status_config_ch1_max_label = QLabel('Max:') self.led_config_ch0_combo = QComboBox() self.led_config_ch0_combo.addItem('Off') self.led_config_ch0_combo.addItem('On') self.led_config_ch0_combo.addItem('Show Heartbeat') self.led_config_ch0_combo.addItem('Show Channel Status') self.led_config_ch0_combo.setSizePolicy(h_sp) self.led_config_ch0_combo.currentIndexChanged.connect( self.led_config_ch0_combo_changed) self.led_config_ch1_combo = QComboBox() self.led_config_ch1_combo.addItem('Off') self.led_config_ch1_combo.addItem('On') self.led_config_ch1_combo.addItem('Show Heartbeat') self.led_config_ch1_combo.addItem('Show Channel Status') self.led_config_ch1_combo.setSizePolicy(h_sp) self.led_config_ch1_combo.currentIndexChanged.connect( self.led_config_ch1_combo_changed) self.led_status_config_ch0_combo = QComboBox() self.led_status_config_ch0_combo.addItem('Threshold') self.led_status_config_ch0_combo.addItem('Intensity') self.led_status_config_ch0_combo.setSizePolicy(h_sp) self.led_status_config_ch0_combo.currentIndexChanged.connect( self.led_status_config_ch0_combo_changed) self.led_status_config_ch1_combo = QComboBox() self.led_status_config_ch1_combo.addItem('Threshold') self.led_status_config_ch1_combo.addItem('Intensity') self.led_status_config_ch1_combo.setSizePolicy(h_sp) self.led_status_config_ch1_combo.currentIndexChanged.connect( self.led_status_config_ch1_combo_changed) self.led_status_config_ch0_min_sbox = QDoubleSpinBox() self.led_status_config_ch0_max_sbox = QDoubleSpinBox() self.led_status_config_ch1_min_sbox = QDoubleSpinBox() self.led_status_config_ch1_max_sbox = QDoubleSpinBox() self.led_status_config_ch0_min_sbox.setValue(0) self.led_status_config_ch0_min_sbox.setMinimum(0) self.led_status_config_ch0_min_sbox.setSingleStep(0.5) self.led_status_config_ch0_min_sbox.setDecimals(3) self.led_status_config_ch0_min_sbox.setSuffix(' mA') self.led_status_config_ch0_min_sbox.setMaximum(22.5) self.led_status_config_ch0_min_sbox.valueChanged.connect( self.led_status_config_ch0_min_sbox_changed) self.led_status_config_ch0_max_sbox.setValue(0) self.led_status_config_ch0_max_sbox.setMinimum(0) self.led_status_config_ch0_max_sbox.setSingleStep(0.5) self.led_status_config_ch0_max_sbox.setDecimals(3) self.led_status_config_ch0_max_sbox.setSuffix(' mA') self.led_status_config_ch0_max_sbox.setMaximum(22.5) self.led_status_config_ch0_max_sbox.valueChanged.connect( self.led_status_config_ch0_max_sbox_changed) self.led_status_config_ch1_min_sbox.setValue(0) self.led_status_config_ch1_min_sbox.setMinimum(0) self.led_status_config_ch1_min_sbox.setSingleStep(0.5) self.led_status_config_ch1_min_sbox.setDecimals(3) self.led_status_config_ch1_min_sbox.setSuffix(' mA') self.led_status_config_ch1_min_sbox.setMaximum(22.5) self.led_status_config_ch1_min_sbox.valueChanged.connect( self.led_status_config_ch1_min_sbox_changed) self.led_status_config_ch1_max_sbox.setValue(0) self.led_status_config_ch1_max_sbox.setMinimum(0) self.led_status_config_ch1_max_sbox.setSingleStep(0.5) self.led_status_config_ch1_max_sbox.setDecimals(3) self.led_status_config_ch1_max_sbox.setSuffix(' mA') self.led_status_config_ch1_max_sbox.setMaximum(22.5) self.led_status_config_ch1_max_sbox.valueChanged.connect( self.led_status_config_ch1_max_sbox_changed) hlayout = QHBoxLayout() self.led_status_config_ch0_min_sbox.setSizePolicy(h_sp) self.led_status_config_ch0_max_sbox.setSizePolicy(h_sp) hlayout.addWidget(self.led_status_config_ch0_min_label) hlayout.addWidget(self.led_status_config_ch0_min_sbox) hlayout.addWidget(self.led_status_config_ch0_max_label) hlayout.addWidget(self.led_status_config_ch0_max_sbox) hlayout1 = QHBoxLayout() self.led_status_config_ch1_min_sbox.setSizePolicy(h_sp) self.led_status_config_ch1_max_sbox.setSizePolicy(h_sp) hlayout1.addWidget(self.led_status_config_ch1_min_label) hlayout1.addWidget(self.led_status_config_ch1_min_sbox) hlayout1.addWidget(self.led_status_config_ch1_max_label) hlayout1.addWidget(self.led_status_config_ch1_max_sbox) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) line1 = QFrame() line1.setObjectName("line1") line1.setFrameShape(QFrame.HLine) line1.setFrameShadow(QFrame.Sunken) line2 = QFrame() line2.setObjectName("line2") line2.setFrameShape(QFrame.HLine) line2.setFrameShadow(QFrame.Sunken) glayout = QGridLayout() glayout.addWidget(line, 0, 0, 1, 3) # line-1 glayout.addWidget(self.sample_rate_label, 1, 0, 1, 1) glayout.addWidget(self.sample_rate_combo, 1, 1, 1, 2) glayout.addWidget(self.gain_label, 2, 0, 1, 1) glayout.addWidget(self.gain_combo, 2, 1, 1, 2) glayout.addWidget(line1, 3, 0, 1, 3) # line-2 glayout.addWidget(self.led_config_ch0_label, 4, 1, 1, 1) glayout.addWidget(self.led_config_ch1_label, 4, 2, 1, 1) glayout.addWidget(line2, 5, 0, 1, 3) # line-3 glayout.addWidget(self.led_config_label, 6, 0, 1, 1) glayout.addWidget(self.led_config_ch0_combo, 6, 1, 1, 1) glayout.addWidget(self.led_config_ch1_combo, 6, 2, 1, 1) glayout.addWidget(self.led_status_config_label, 7, 0, 1, 1) glayout.addWidget(self.led_status_config_ch0_combo, 7, 1, 1, 1) glayout.addWidget(self.led_status_config_ch1_combo, 7, 2, 1, 1) glayout.addLayout(hlayout, 8, 1, 1, 1) glayout.addLayout(hlayout1, 8, 2, 1, 1) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addLayout(glayout) self.ui_group_ch_status_ch0 = [ self.led_status_config_ch0_combo, self.led_status_config_ch0_min_sbox, self.led_status_config_ch0_max_sbox ] self.ui_group_ch_status_ch1 = [ self.led_status_config_ch1_combo, self.led_status_config_ch1_min_sbox, self.led_status_config_ch1_max_sbox ]
def __init__(self, parent=None, **kw): # the current button self._ActiveButton = Qt.NoButton # private attributes self.__saveX = 0 self.__saveY = 0 self.__saveModifiers = Qt.NoModifier self.__saveButtons = Qt.NoButton self.__wheelDelta = 0 # do special handling of some keywords: # stereo, rw try: stereo = bool(kw['stereo']) except KeyError: stereo = False try: rw = kw['rw'] except KeyError: rw = None # create base qt-level widget if QVTKRWIBase == "QWidget": if "wflags" in kw: wflags = kw['wflags'] else: wflags = Qt.WindowFlags() QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC) elif QVTKRWIBase == "QGLWidget": QGLWidget.__init__(self, parent) if rw: # user-supplied render window self._RenderWindow = rw else: self._RenderWindow = vtk.vtkRenderWindow() WId = self.winId() print 'WId=', WId # print 'widget id = ', widget.winId() win_id = int(WId) print 'win_id=', win_id l_int = c_long(win_id) # lib.cpp_disableGLHiDPI(4621918512) lib.cpp_disableGLHiDPI(l_int) # # disableGLHiDPI(widget.winId()) # Python2 if type(WId).__name__ == 'PyCObject': from ctypes import pythonapi, c_void_p, py_object pythonapi.PyCObject_AsVoidPtr.restype = c_void_p pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object] WId = pythonapi.PyCObject_AsVoidPtr(WId) # Python3 elif type(WId).__name__ == 'PyCapsule': from ctypes import pythonapi, c_void_p, py_object, c_char_p pythonapi.PyCapsule_GetName.restype = c_char_p pythonapi.PyCapsule_GetName.argtypes = [py_object] name = pythonapi.PyCapsule_GetName(WId) pythonapi.PyCapsule_GetPointer.restype = c_void_p pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p] WId = pythonapi.PyCapsule_GetPointer(WId, name) self._RenderWindow.SetWindowInfo(str(int(WId))) # if stereo: # stereo mode # self._RenderWindow.StereoCapableWindowOn() # self._RenderWindow.SetStereoTypeToCrystalEyes() try: self._Iren = kw['iren'] except KeyError: self._Iren = vtk.vtkGenericRenderWindowInteractor() self._Iren.SetRenderWindow(self._RenderWindow) # this is needed to get nice'n'smooth mouse interaction self.interactorStyle = vtk.vtkInteractorStyleSwitch() # self.interactorStyle.SetCurrentStyleToTrackballActor() self.interactorStyle.SetCurrentStyleToTrackballCamera() self._Iren.SetInteractorStyle(self.interactorStyle) # do all the necessary qt setup self.setAttribute(Qt.WA_OpaquePaintEvent) self.setAttribute(Qt.WA_PaintOnScreen) self.setMouseTracking(True) # get all mouse events self.setFocusPolicy(Qt.WheelFocus) self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self._Timer = QTimer(self) self._Timer.timeout.connect(self.TimerEvent) self._Iren.AddObserver('CreateTimerEvent', self.CreateTimer) self._Iren.AddObserver('DestroyTimerEvent', self.DestroyTimer) self._Iren.GetRenderWindow().AddObserver('CursorChangedEvent', self.CursorChangedEvent) #Create a hidden child widget and connect its destroyed signal to its #parent ``Finalize`` slot. The hidden children will be destroyed before #its parent thus allowing cleanup of VTK elements. self._hidden = QWidget(self) self._hidden.hide() self._hidden.destroyed.connect(self.Finalize) self.mousePressEventFcn = self.mousePressEvent2DStyle
def SetVirtualButtons(self):#рисуем кнопки с длинным нажатием self.StartVirt1 = LongButton(self.centralwidget, name="StartVirt1") self.StartVirt1.setGeometry(QtCore.QRect(15, 75, 134, 139)) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.StartVirt1.sizePolicy().hasHeightForWidth()) self.StartVirt1.setSizePolicy(sizePolicy) self.StartVirt1.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) self.StartVirt1.setFocusPolicy(QtCore.Qt.NoFocus) self.StartVirt1.setContextMenuPolicy(QtCore.Qt.NoContextMenu) self.StartVirt1.setAcceptDrops(False) self.StartVirt1.setStyleSheet(_fromUtf8("border-style: outset;background-color: none;")) self.StopVirt1 = LongButton(self.centralwidget, name="StopVirt1") self.StopVirt1.setGeometry(QtCore.QRect(15, 227, 134, 139)) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.StopVirt1.sizePolicy().hasHeightForWidth()) self.StopVirt1.setSizePolicy(sizePolicy) self.StopVirt1.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) self.StopVirt1.setFocusPolicy(QtCore.Qt.NoFocus) self.StopVirt1.setContextMenuPolicy(QtCore.Qt.NoContextMenu) self.StopVirt1.setAcceptDrops(False) self.StopVirt1.setStyleSheet(_fromUtf8("border-style: outset;background-color: none;")) self.StartVirt2 = LongButton(self.centralwidget, name="StartVirt2") self.StartVirt2.setGeometry(QtCore.QRect(651, 75, 134, 139)) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.StartVirt2.sizePolicy().hasHeightForWidth()) self.StartVirt2.setSizePolicy(sizePolicy) self.StartVirt2.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) self.StartVirt2.setFocusPolicy(QtCore.Qt.NoFocus) self.StartVirt2.setContextMenuPolicy(QtCore.Qt.NoContextMenu) self.StartVirt2.setAcceptDrops(False) self.StartVirt2.setStyleSheet(_fromUtf8("border-style: outset;background-color: none;")) self.StopVirt2 = LongButton(self.centralwidget, name="StopVirt2") self.StopVirt2.setGeometry(QtCore.QRect(651, 227, 134, 139)) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.StopVirt2.sizePolicy().hasHeightForWidth()) self.StopVirt2.setSizePolicy(sizePolicy) self.StopVirt2.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) self.StopVirt2.setFocusPolicy(QtCore.Qt.NoFocus) self.StopVirt2.setContextMenuPolicy(QtCore.Qt.NoContextMenu) self.StopVirt2.setAcceptDrops(False) self.StopVirt2.setStyleSheet(_fromUtf8("border-style: outset;background-color: none;")) self.lockVirt = LongButton(self.centralwidget, name="lockVirt") self.lockVirt.setGeometry(QtCore.QRect(322, 836, 150, 148)) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.lockVirt.sizePolicy().hasHeightForWidth()) self.lockVirt.setSizePolicy(sizePolicy) self.lockVirt.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) self.lockVirt.setFocusPolicy(QtCore.Qt.NoFocus) self.lockVirt.setContextMenuPolicy(QtCore.Qt.NoContextMenu) self.lockVirt.setAcceptDrops(False) self.lockVirt.setStyleSheet(_fromUtf8("border-style: outset;background-color: none;"))
def __init__(self): super().__init__() self.in_data = None self.in_distance = None self.in_learner = None self.in_classifier = None self.in_object_1 = None self.in_object_2 = None self.in_object_3 = None self.in_object_4 = None self.in_object_5 = None self.in_object_6 = None self.in_object_7 = None self.in_object_8 = None self.in_object_9 = None self.in_object_10 = None # MODIFIED BY LUCA REBUFFI 14/10/2014 #self.auto_execute = False for s in self.libraryListSource: s.flags = 0 self._cachedDocuments = {} self.infoBox = gui.widgetBox(self.controlArea, 'Info') gui.label( self.infoBox, self, "<p>Execute python script.</p><p>Input variables:<ul><li> " + \ "<li>".join([self.inputs[0].name, ".",".",".", self.inputs[-1].name]) + \ "</ul></p><p>Output variables:<ul><li>" + \ "<li>".join(t.name for t in self.outputs) + \ "</ul></p>" ) self.optionBox = oasysgui.widgetBox(self.controlArea, 'Options') gui.comboBox(self.optionBox, self, "font_size", label="Font Size", labelWidth=120, items=self.fonts, sendSelectedValue=False, orientation="horizontal", callback=self.changeFont) self.libraryList = itemmodels.PyListModel( [], self, flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable) self.libraryList.wrap(self.libraryListSource) self.controlBox = gui.widgetBox(self.controlArea, 'Library') self.controlBox.layout().setSpacing(1) self.libraryView = QListView( editTriggers=QListView.DoubleClicked | QListView.EditKeyPressed, sizePolicy=QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)) self.libraryView.setItemDelegate(ScriptItemDelegate(self)) self.libraryView.setModel(self.libraryList) self.libraryView.selectionModel().selectionChanged.connect( self.onSelectedScriptChanged) self.controlBox.layout().addWidget(self.libraryView) w = itemmodels.ModelActionsWidget() self.addNewScriptAction = action = QAction("+", self) action.setToolTip("Add a new script to the library") action.triggered.connect(self.onAddScript) w.addAction(action) action = QAction(unicodedata.lookup("MINUS SIGN"), self) action.setToolTip("Remove script from library") action.triggered.connect(self.onRemoveScript) w.addAction(action) action = QAction("Update", self) action.setToolTip("Save changes in the editor to library") action.setShortcut(QKeySequence(QKeySequence.Save)) action.triggered.connect(self.commitChangesToLibrary) w.addAction(action) action = QAction("More", self, toolTip="More actions") new_from_file = QAction("Import a script from a file", self) save_to_file = QAction("Save selected script to a file", self) save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs)) new_from_file.triggered.connect(self.onAddScriptFromFile) save_to_file.triggered.connect(self.saveScript) menu = QMenu(w) menu.addAction(new_from_file) menu.addAction(save_to_file) action.setMenu(menu) button = w.addAction(action) button.setPopupMode(QToolButton.InstantPopup) w.layout().setSpacing(1) self.controlBox.layout().addWidget(w) self.runBox = gui.widgetBox(self.controlArea, 'Run') gui.button(self.runBox, self, "Execute", callback=self.execute) gui.checkBox(self.runBox, self, "auto_execute", "Auto execute", tooltip="Run the script automatically whenever " + "the inputs to the widget change.") self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitCanvas) self.defaultFont = defaultFont = \ "Monaco" if sys.platform == "darwin" else "Courier" self.textBox = gui.widgetBox(self, 'Python script') self.splitCanvas.addWidget(self.textBox) self.text = PythonScriptEditor(self) self.textBox.layout().addWidget(self.text) self.textBox.setAlignment(Qt.AlignVCenter) self.text.setTabStopWidth(4) self.text.modificationChanged[bool].connect(self.onModificationChanged) self.saveAction = action = QAction("&Save", self.text) action.setToolTip("Save script to file") action.setShortcut(QKeySequence(QKeySequence.Save)) action.setShortcutContext(Qt.WidgetWithChildrenShortcut) action.triggered.connect(self.saveScript) self.consoleBox = gui.widgetBox(self, 'Console') self.splitCanvas.addWidget(self.consoleBox) self.console = PythonConsole(self.__dict__, self) self.consoleBox.layout().addWidget(self.console) self.console.document().setDefaultFont(QFont(defaultFont)) self.consoleBox.setAlignment(Qt.AlignBottom) self.console.setTabStopWidth(4) select_row(self.libraryView, self.currentScriptIndex) self.splitCanvas.setSizes([2, 1]) if self.splitterState is not None: self.splitCanvas.restoreState( QByteArray(bytearray(self.splitterState, "ascii"))) self.splitCanvas.splitterMoved[int, int].connect(self.onSpliterMoved) self.controlArea.layout().addStretch(1) self.resize(800, 600) self.changeFont()
def __init__(self, meminfo, parent=None): super(HexViewWidget, self).__init__() self.setupUi(self) self._meminfo = meminfo self._model = HexTableModel(self._meminfo) self._origins = [] # ripped from pyuic5 ui/hexview.ui # at commit 6c9edffd32706097d7eba8814d306ea1d997b25a # so we can add our custom HexTableView instance self.view = HexTableView(self) sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.view.sizePolicy().hasHeightForWidth()) self.view.setSizePolicy(sizePolicy) self.view.setMinimumSize(QSize(660, 0)) self.view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.view.setSelectionMode(QAbstractItemView.NoSelection) self.view.setShowGrid(False) self.view.setWordWrap(False) self.view.setObjectName("view") self.view.verticalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.mainLayout.insertWidget(0, self.view) # end rip # TODO: provide a HexViewWidget.setModel method, and don't build it # ourselves self.view.setModel(self._model) self.hheader = self.view.horizontalHeader() self.hheader.setSectionResizeMode(QHeaderView.ResizeToContents) # separator column self.hheader.setSectionResizeMode(0x10, QHeaderView.Interactive) self.view.setColumnWidth(0x10, 5) self._hsm = HexItemSelectionModel(self._model, self.view) self.view.setSelectionModel(self._hsm) self.view.setContextMenuPolicy(Qt.CustomContextMenu) self.view.customContextMenuRequested.connect( self._handle_context_menu_requested) self._hsm.selectionRangeChanged.connect( self._handle_selection_range_changed) self.originsChanged.connect(self._handle_origins_changed) self.view.moveKeyPressed.connect(self._hsm.handle_move_key) self.view.selectKeyPressed.connect(self._hsm.handle_select_key) f = QFont("Monospace") f = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.view.setFont(f) self.statusLabel.setFont(f) self.view.setItemDelegate(HexItemDelegate(self._model, self)) self.statusLabel.setText("")
def __init__(self, exer, view): super(OpenPoseWidget, self).__init__() self.main_layout = QHBoxLayout() self.op_layout = QVBoxLayout() self.control_layout = QVBoxLayout() self.start_control = 0 # op_layout op_tmp = QLabel('Please push Start button') op_tmp.setAlignment(Qt.AlignCenter) self.op_layout.addWidget(op_tmp) # contorl_layout self.sub1_layout = QHBoxLayout() self.sub2_layout = QVBoxLayout() start = QPushButton('Start') stop = QPushButton('Stop') feedback = QPushButton('Feedback') font = QFont('Arial', 20) start.setFont(font) stop.setFont(font) feedback.setFont(font) start.setFixedSize(QSize(150,75)) stop.setFixedSize(QSize(150,75)) feedback.setFixedSize(QSize(150,75)) start.clicked.connect(partial(self.run_op_screen, exer, view)) stop.clicked.connect(partial(self.stop_op_screen)) feedback.clicked.connect(partial(self.start_feedback)) self.sub1_layout.addWidget(start) self.sub1_layout.addWidget(stop) self.sub1_layout.addWidget(feedback) msg = "" if exer == 'squat': msg += "스쿼트를 선택하셨습니다.\n" else: msg += "푸쉬업을 선택하셨습니다.\n" msg += "영상 촬영을 시작하기 위해서 버튼을 눌러주세요. \n" + \ "시작되는데 15초 가량 소요될 수 있습니다." label1 = QLabel(msg) label1.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) font = QFont('Arial', 15) label1.setFont(font) self.exer_img = QLabel() if exer == 'squat': self.exer_img.setPixmap(QPixmap("../pictures/squat.JPG").scaledToWidth(320)) else: self.exer_img.setPixmap(QPixmap("../pictures/pushup.JPG").scaledToWidth(320)) self.exer_img.setAlignment(Qt.AlignCenter) self.sub2_layout.addWidget(self.exer_img) #self.sub2_layout.addWidget(label1) #self.sub2_layout.addWidget(label2) #self.control_layout.addLayout(self.sub1_layout) self.control_layout.addLayout(self.sub2_layout) right_layout = QVBoxLayout() right_layout.addLayout(self.op_layout) right_layout.addLayout(self.sub1_layout) # main_layout self.main_layout.addLayout(self.control_layout) self.main_layout.addLayout(right_layout) #self.main_layout.addLayout(self.op_layout) self.setLayout(self.main_layout)
def __init__(self, parent=None, **kw): # the current button self._ActiveButton = Qt.NoButton # private attributes self.__saveX = 0 self.__saveY = 0 self.__saveModifiers = Qt.NoModifier self.__saveButtons = Qt.NoButton self.__wheelDelta = 0 # do special handling of some keywords: # stereo, rw try: stereo = bool(kw['stereo']) except KeyError: stereo = False try: rw = kw['rw'] except KeyError: rw = None # create qt-level widget if QVTKRWIBase == "QWidget": if "wflags" in kw: wflags = kw['wflags'] else: wflags = Qt.WindowFlags() QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC) elif QVTKRWIBase == "QGLWidget": QGLWidget.__init__(self, parent) if rw: # user-supplied render window self._RenderWindow = rw else: self._RenderWindow = vtk.vtkRenderWindow() wid = self._get_win_id() self._RenderWindow.SetWindowInfo(wid) self._should_set_parent_info = (sys.platform == 'win32') if stereo: # stereo mode self._RenderWindow.StereoCapableWindowOn() self._RenderWindow.SetStereoTypeToCrystalEyes() try: self._Iren = kw['iren'] except KeyError: self._Iren = vtk.vtkGenericRenderWindowInteractor() self._Iren.SetRenderWindow(self._RenderWindow) if hasattr(self, 'devicePixelRatio'): self._pixel_ratio = self.devicePixelRatio() else: self._pixel_ratio = 1.0 # do all the necessary qt setup self.setAttribute(Qt.WA_OpaquePaintEvent) self.setAttribute(Qt.WA_PaintOnScreen) self.setMouseTracking(True) # get all mouse events self.setFocusPolicy(Qt.WheelFocus) self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self._Timer = QTimer(self) self._Timer.timeout.connect(self.TimerEvent) # add wheel timer to fix scrolling issue with trackpad self.wheel_timer = None if PyQtImpl != 'PyQt5': self.wheel_timer = QTimer() self.wheel_timer.setSingleShot(True) self.wheel_timer.setInterval(25) self.wheel_timer.timeout.connect(self._emit_wheel_event) self._saved_wheel_event_info = () self._Iren.AddObserver('CreateTimerEvent', messenger.send) messenger.connect(self._Iren, 'CreateTimerEvent', self.CreateTimer) self._Iren.AddObserver('DestroyTimerEvent', messenger.send) messenger.connect(self._Iren, 'DestroyTimerEvent', self.DestroyTimer) self._RenderWindow.AddObserver('CursorChangedEvent', messenger.send) messenger.connect(self._RenderWindow, 'CursorChangedEvent', self.CursorChangedEvent) # Create a hidden child widget and connect its destroyed signal to its # parent ``Finalize`` slot. The hidden children will be destroyed # before its parent thus allowing cleanup of VTK elements. self._hidden = QWidget(self) self._hidden.hide() self._hidden.destroyed.connect(self.Finalize)
def start_feedback(self): #time.sleep(5) #collect data print("feedback start") print("GET READY") time.sleep(3) print("START") #for i in reversed(range(self.sub2_layout.count())): # self.sub2_layout.itemAt(i).widget().setParent(None) #go_img = QLabel("GO") #go_img.setPixmap(QPixmap("../pictures/go.JPG").scaledToWidth(320)) #go_img.setAlignment(Qt.AlignCenter) #self.sub2_layout.addWidget(go_img) start_point = len(os.listdir(json_dir)) j = JsonParser(start_point=start_point) # incremental try frame_no_list = [i*10 for i in range(4,10)] err = 0 tys = ["elbow", "arm", "shoulder"] result_dict = {} for frame_no in frame_no_list: print(str(frame_no) + " frame test") video = j.parse(None, frame_no , json_dir, "front", None) result_dict = {} err = 0 for ty in tys: print("doing " + ty) fds = FeedbackSystem() fds.load("demo_front_" + ty + "_model", "front") result, div_zero = fds.feedback_kmeans(video, ty, threshold=0.3) if div_zero: err = 1 else: result_dict[ty] = result if err is 0: break if err is 1: self.stop_op_screen("Posture is not detected. Please adjust webcam position") return fdm = FeedbackMsg(result_dict) msg = fdm.get_feedback_msg() #self.op_handler.terminate() # now print out feedback msg #self.stop_op_screen("Result") need_cor = msg[0] cor_msg = msg[1:] #top_layout = QVBoxLayout() #bottom_layout = QVBoxLayout() """ for m in cor_msg: op_tmp = QLabel(m) op_tmp.setAlignment(Qt.AlignCenter) self.op_layout.addWidget(op_tmp) """ for i in reversed(range(self.sub2_layout.count())): self.sub2_layout.itemAt(i).widget().setParent(None) if need_cor: bad_img = QLabel() bad_img.setPixmap(QPixmap("../pictures/bad.JPG").scaledToWidth(260)) bad_img.setAlignment(Qt.AlignCenter) self.sub2_layout.addWidget(bad_img) else: nice_img = QLabel() nice_img.setPixmap(QPixmap("../pictures/nice.JPG").scaledToWidth(260)) nice_img.setAlignment(Qt.AlignCenter) self.sub2_layout.addWidget(nice_img) feedback_msg = "" for m in cor_msg: feedback_msg += m + "\n" op_tmp = QLabel(feedback_msg) op_tmp.setAlignment(Qt.AlignCenter) op_tmp.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.sub2_layout.addWidget(op_tmp) """
def __init__(self): super(HardwareFilter, self).__init__() self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.layoutingComplete = False self.setUi()
def __init__(self): super().__init__() self.filename = None self.icon_bar = QWidget() self.icon_bar.setStyleSheet('background-color: silver') policy = QSizePolicy() policy.setRetainSizeWhenHidden(True) self.icon_bar.setSizePolicy(policy) #home directory of the user self.home_dict = str(Path.home()) # widget which contains the icons self.iconBox = QHBoxLayout(self.icon_bar) self.iconBox.setContentsMargins(8, 0, 0, 0) # buttons self.save_as_button = SaveAsButton() self.save_button = SaveButton() self.open_file_button = OpenFile() self.new_file_button = NewFile() self.run_button = RunButton() self.start_debug_button = StartDebugButton() self.stop_exec_button = StopExecButton() self.kill_proc_button = KillProcButton() # Logo self.logo_horizontal = QLabel() logo_height = self.save_as_button.pixmap().height() * 1.5 self.logo_horizontal.setPixmap( QPixmap('images/horizontal_blur.png').scaledToHeight(logo_height)) self.logo_horizontal.pixmap() # change the icons background self.save_as_button.mousePressEvent = self.saveFileDialog self.save_as_button.saveAsHover.connect(self.setInfoText) self.save_button.mousePressEvent = self.simpleSave self.save_button.saveHover.connect(self.setInfoText) self.open_file_button.mousePressEvent = self.openFileNameDialog self.open_file_button.openHover.connect(self.setInfoText) self.run_button.runHover.connect(self.setInfoText) self.run_button.mousePressEvent = (self.startExec) self.start_debug_button.startDebugHover.connect(self.setInfoText) self.start_debug_button.mousePressEvent = self.startDebug self.new_file_button.mousePressEvent = self.saveQuestion self.new_file_button.newHover.connect(self.setInfoText) self.stop_exec_button.mousePressEvent = self.stop_execution self.stop_exec_button.stopExecHover.connect(self.setInfoText) self.kill_proc_button.mousePressEvent = self.killProc self.kill_proc_button.killProcHover.connect(self.setInfoText) self.iconBox.addWidget(self.new_file_button) self.iconBox.addWidget(self.open_file_button) self.iconBox.addWidget(self.save_as_button) self.iconBox.addWidget(self.save_button) self.iconBox.addWidget(self.start_debug_button) self.iconBox.addWidget(self.run_button) self.iconBox.addWidget(self.stop_exec_button) self.iconBox.addWidget(self.kill_proc_button) self.iconBox.addStretch(1) self.iconBox.addWidget(self.logo_horizontal) self.iconBox.setContentsMargins(3, 3, 0, 0) self.setLayout(self.iconBox)
def __init__(self, parent, table_model): super(AbstractTableView, self).__init__() self.tableView = QTableView(parent) self.table_model = table_model # Set behaviour of table self.tableView.setAlternatingRowColors(True) # Set model # do not add sorting without handling buttons sorting self.tableView.setModel(self.table_model) # add row PushButton # self.insert_button() # styleofmytable self.tableView.setStyleSheet(''' QWidget { background-color: #EFF6EE; color: #191712; } QHeaderView::section { background-color: #233043; color: #EFF6EE; padding: 4px; border: 1px solid #fffff8; font-size: 14pt; } QTableWidget { gridline-color: #fffff8; font-size: 12pt; } QTableWidget QTableCornerButton::section { background-color: #646464; border: 1px solid #fffff8; } ''') self.tableView.setStyleSheet(''' ''') # Set Column size self.tableView.setSortingEnabled(False) self.tableView.verticalHeader().hide() self.tableView.setColumnWidth(0, 90) self.tableView.setColumnWidth(1, 190) self.tableView.setColumnWidth(2, 550) self.tableView.setColumnWidth(3, 270) self.tableView.setColumnWidth(4, 110) self.tableView.setColumnWidth(5, 120) self.tableView.setColumnWidth(6, 162) # column behaviour self.tableView.horizontalHeader().setSectionResizeMode( 0, QHeaderView.Stretch) self.tableView.horizontalHeader().setSectionResizeMode( 1, QHeaderView.Stretch) self.tableView.horizontalHeader().setSectionResizeMode( 2, QHeaderView.Stretch) self.tableView.horizontalHeader().setSectionResizeMode( 3, QHeaderView.Stretch) self.tableView.horizontalHeader().setSectionResizeMode( 4, QHeaderView.Stretch) self.tableView.horizontalHeader().setSectionResizeMode( 5, QHeaderView.Stretch) # Set Size Policy sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.tableView.sizePolicy().hasHeightForWidth()) self.tableView.setSizePolicy(sizePolicy)
def setup_ui(self, open_patient_window_instance): if platform.system() == 'Darwin': self.stylesheet_path = "src/res/stylesheet.qss" else: self.stylesheet_path = "src/res/stylesheet-win-linux.qss" stylesheet = open(resource_path(self.stylesheet_path)).read() window_icon = QIcon() window_icon.addPixmap( QPixmap(resource_path("src/res/images/icon.ico")), QIcon.Normal, QIcon.Off) open_patient_window_instance.setObjectName("OpenPatientWindowInstance") open_patient_window_instance.setWindowIcon(window_icon) open_patient_window_instance.resize(840, 530) # Create a vertical box for containing the other elements and layouts self.open_patient_window_instance_vertical_box = QVBoxLayout() self.open_patient_window_instance_vertical_box.setObjectName( "OpenPatientWindowInstanceVerticalBox") # Create a label to prompt the user to enter the path to the directory that contains the DICOM files self.open_patient_directory_prompt = QLabel() self.open_patient_directory_prompt.setObjectName( "OpenPatientDirectoryPrompt") self.open_patient_directory_prompt.setAlignment(Qt.AlignLeft) self.open_patient_window_instance_vertical_box.addWidget( self.open_patient_directory_prompt) # Create a horizontal box to hold the input box for the directory and the choose button self.open_patient_directory_input_horizontal_box = QHBoxLayout() self.open_patient_directory_input_horizontal_box.setObjectName( "OpenPatientDirectoryInputHorizontalBox") # Create a textbox to contain the path to the directory that contains the DICOM files self.open_patient_directory_input_box = UIOpenPatientWindowDragAndDropEvent( self) self.open_patient_directory_input_box.setObjectName( "OpenPatientDirectoryInputBox") self.open_patient_directory_input_box.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.open_patient_directory_input_box.returnPressed.connect( self.scan_directory_for_patient) self.open_patient_directory_input_horizontal_box.addWidget( self.open_patient_directory_input_box) # Create a choose button to open the file dialog self.open_patient_directory_choose_button = QPushButton() self.open_patient_directory_choose_button.setObjectName( "OpenPatientDirectoryChooseButton") self.open_patient_directory_choose_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.open_patient_directory_choose_button.resize( self.open_patient_directory_choose_button.sizeHint().width(), self.open_patient_directory_input_box.height()) self.open_patient_directory_choose_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.open_patient_directory_input_horizontal_box.addWidget( self.open_patient_directory_choose_button) self.open_patient_directory_choose_button.clicked.connect( self.choose_button_clicked) # Create a widget to hold the input fields self.open_patient_directory_input_widget = QWidget() self.open_patient_directory_input_horizontal_box.setStretch(0, 4) self.open_patient_directory_input_widget.setLayout( self.open_patient_directory_input_horizontal_box) self.open_patient_window_instance_vertical_box.addWidget( self.open_patient_directory_input_widget) # Create a horizontal box to hold the stop button and direction to the user on where to select the patient self.open_patient_appear_prompt_and_stop_horizontal_box = QHBoxLayout() self.open_patient_appear_prompt_and_stop_horizontal_box.setObjectName( "OpenPatientAppearPromptAndStopHorizontalBox") # Create a label to show direction on where the files will appear self.open_patient_directory_appear_prompt = QLabel() self.open_patient_directory_appear_prompt.setObjectName( "OpenPatientDirectoryAppearPrompt") self.open_patient_directory_appear_prompt.setAlignment(Qt.AlignLeft) self.open_patient_appear_prompt_and_stop_horizontal_box.addWidget( self.open_patient_directory_appear_prompt) self.open_patient_appear_prompt_and_stop_horizontal_box.addStretch(1) # Create a button to stop searching self.open_patient_window_stop_button = QPushButton() self.open_patient_window_stop_button.setObjectName( "OpenPatientWindowStopButton") self.open_patient_window_stop_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.open_patient_window_stop_button.resize( self.open_patient_window_stop_button.sizeHint().width(), self.open_patient_window_stop_button.sizeHint().height()) self.open_patient_window_stop_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.open_patient_window_stop_button.clicked.connect( self.stop_button_clicked) self.open_patient_window_stop_button.setProperty( "QPushButtonClass", "fail-button") self.open_patient_window_stop_button.setVisible( False) # Button doesn't show until a search commences self.open_patient_appear_prompt_and_stop_horizontal_box.addWidget( self.open_patient_window_stop_button) # Create a widget to hold the layout self.open_patient_appear_prompt_and_stop_widget = QWidget() self.open_patient_appear_prompt_and_stop_widget.setLayout( self.open_patient_appear_prompt_and_stop_horizontal_box) self.open_patient_window_instance_vertical_box.addWidget( self.open_patient_appear_prompt_and_stop_widget) # Create a tree view list to list out all patients in the directory selected above self.open_patient_window_patients_tree = QTreeWidget() self.open_patient_window_patients_tree.setObjectName( "OpenPatientWindowPatientsTree") self.open_patient_window_patients_tree.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.open_patient_window_patients_tree.resize( self.open_patient_window_patients_tree.sizeHint().width(), self.open_patient_window_patients_tree.sizeHint().height()) self.open_patient_window_patients_tree.setHeaderHidden(True) self.open_patient_window_patients_tree.setHeaderLabels([""]) self.open_patient_window_instance_vertical_box.addWidget( self.open_patient_window_patients_tree) # Create a label to show what would happen if they select the patient self.open_patient_directory_result_label = QtWidgets.QLabel() self.open_patient_directory_result_label.setObjectName( "OpenPatientDirectoryResultLabel") self.open_patient_directory_result_label.setAlignment(Qt.AlignLeft) self.open_patient_window_instance_vertical_box.addWidget( self.open_patient_directory_result_label) # Create a horizontal box to hold the Cancel and Open button self.open_patient_window_patient_open_actions_horizontal_box = QHBoxLayout( ) self.open_patient_window_patient_open_actions_horizontal_box.setObjectName( "OpenPatientWindowPatientOpenActionsHorizontalBox") self.open_patient_window_patient_open_actions_horizontal_box.addStretch( 1) # Add a button to go back/exit from the application self.open_patient_window_exit_button = QPushButton() self.open_patient_window_exit_button.setObjectName( "OpenPatientWindowExitButton") self.open_patient_window_exit_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.open_patient_window_exit_button.resize( self.open_patient_window_stop_button.sizeHint().width(), self.open_patient_window_stop_button.sizeHint().height()) self.open_patient_window_exit_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.open_patient_window_exit_button.clicked.connect( self.exit_button_clicked) self.open_patient_window_exit_button.setProperty( "QPushButtonClass", "fail-button") self.open_patient_window_patient_open_actions_horizontal_box.addWidget( self.open_patient_window_exit_button) # Add a button to confirm opening of the patient self.open_patient_window_confirm_button = QPushButton() self.open_patient_window_confirm_button.setObjectName( "OpenPatientWindowConfirmButton") self.open_patient_window_confirm_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.open_patient_window_confirm_button.resize( self.open_patient_window_confirm_button.sizeHint().width(), self.open_patient_window_confirm_button.sizeHint().height()) self.open_patient_window_confirm_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.open_patient_window_confirm_button.clicked.connect( self.confirm_button_clicked) self.open_patient_window_confirm_button.setProperty( "QPushButtonClass", "success-button") self.open_patient_window_patient_open_actions_horizontal_box.addWidget( self.open_patient_window_confirm_button) # Create a widget to house all of the actions button for open patient window self.open_patient_window_patient_open_actions_widget = QWidget() self.open_patient_window_patient_open_actions_widget.setLayout( self.open_patient_window_patient_open_actions_horizontal_box) self.open_patient_window_instance_vertical_box.addWidget( self.open_patient_window_patient_open_actions_widget) # Set the vertical box fourth element, the tree view, to stretch out as far as possible self.open_patient_window_instance_vertical_box.setStretch( 3, 4) # Stretch the treeview out as far as possible self.open_patient_window_instance_central_widget = QWidget() self.open_patient_window_instance_central_widget.setObjectName( "OpenPatientWindowInstanceCentralWidget") self.open_patient_window_instance_central_widget.setLayout( self.open_patient_window_instance_vertical_box) # Create threadpool for multithreading self.threadpool = QThreadPool() print("Multithreading with maximum %d threads" % self.threadpool.maxThreadCount()) # Create interrupt event for stopping the directory search self.interrupt_flag = threading.Event() # Bind all texts into the buttons and labels self.retranslate_ui(open_patient_window_instance) # Set the central widget, ready for display open_patient_window_instance.setCentralWidget( self.open_patient_window_instance_central_widget) # Set the current stylesheet to the instance and connect it back to the caller through slot open_patient_window_instance.setStyleSheet(stylesheet) QtCore.QMetaObject.connectSlotsByName(open_patient_window_instance)
def setup_ui(self, containers: QFrame, main_gridLayout: QGridLayout): self.frame_location_box = QFrame(containers) self.frame_location_box.setFrameShape(QFrame.StyledPanel) self.frame_location_box.setFrameShadow(QFrame.Raised) self.frame_location_box.setObjectName("frame_location_box") self.vlayout_location_box = QVBoxLayout(self.frame_location_box) self.vlayout_location_box.setContentsMargins(0, 0, 71, 0) self.vlayout_location_box.setObjectName("vlayout_location_box") self.location_box = QLabel(self.frame_location_box) self.location_box.setText("MainPage") self.location_box.setCursor(QCursor(Qt.PointingHandCursor)) self.location_box.setObjectName(TopNavigationBarContainersStyles.location_box_style[0]) self.location_box.setStyleSheet(TopNavigationBarContainersStyles.location_box_style[1]) self.location_box.setAlignment(Qt.AlignCenter) self.location_box.setOpenExternalLinks(False) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.location_box.sizePolicy().hasHeightForWidth()) self.location_box.setSizePolicy(sizePolicy) self.location_box.setMinimumSize(QSize(370, 33)) self.location_box.setMaximumSize(QSize(370, 33)) del sizePolicy self.vlayout_location_box.addWidget(self.location_box, 0, Qt.AlignHCenter) main_gridLayout.addWidget(self.frame_location_box, 0, 2, 1, 1) self.components_frame = QFrame(containers) self.components_frame.setMinimumSize(QSize(181, 51)) self.components_frame.setMaximumSize(QSize(181, 51)) self.components_frame.setFrameShape(QFrame.StyledPanel) self.components_frame.setFrameShadow(QFrame.Raised) self.components_frame.setObjectName("components_frame") self.item_user = QLabel(self.components_frame) self.item_user.setGeometry(QRect(0, 10, 34, 34)) self.item_user.setCursor(QCursor(Qt.PointingHandCursor)) self.item_user.setAccessibleName(TopNavigationBarContainersStyles.item_notification_style[0]) self.item_user.setStyleSheet(TopNavigationBarContainersStyles.item_notification_style[1]) self.item_user.setPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/user_logo.svg")) self.item_user.setAlignment(Qt.AlignCenter) self.item_user.setObjectName("item_user") self.item_message = QLabel(self.components_frame) self.item_message.setObjectName("item_message") self.item_message.setStyleSheet(TopNavigationBarContainersStyles.item_notification_style[1]) self.item_message.setGeometry(QRect(95, 10, 34, 34)) self.item_message.setCursor(QCursor(Qt.PointingHandCursor)) self.item_message.setPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/message_logo.svg")) self.item_message.setAlignment(Qt.AlignCenter) self.item_notification = QLabel(self.components_frame) self.item_notification.setGeometry(QRect(47, 10, 34, 34)) self.item_notification.setCursor(QCursor(Qt.PointingHandCursor)) self.item_notification.setAccessibleName(TopNavigationBarContainersStyles.item_notification_style[0]) self.item_notification.setStyleSheet(TopNavigationBarContainersStyles.item_notification_style[1]) self.item_notification.setPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/notification_logo.svg")) self.item_notification.setAlignment(Qt.AlignCenter) self.item_notification.setObjectName("item_notification") self.item_search = QLabel(self.components_frame) self.item_search.setObjectName("item_search") self.item_search.setGeometry(QRect(142, 10, 34, 34)) self.item_search.setCursor(QCursor(Qt.PointingHandCursor)) self.item_search.setAccessibleName(TopNavigationBarContainersStyles.item_notification_style[0]) self.item_search.setStyleSheet(TopNavigationBarContainersStyles.item_notification_style[1]) self.item_search.setPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/search_logo.svg")) self.item_search.setAlignment(Qt.AlignCenter) self.lbl_number_of_message = QLabel(self.components_frame) self.lbl_number_of_message.setGeometry(QRect(110, 5, 31, 26)) self.lbl_number_of_message.setText("+25") self.lbl_number_of_message.setAlignment(Qt.AlignCenter) self.lbl_number_of_message.setObjectName(TopNavigationBarContainersStyles.notify_number_of_box_style[0]) self.lbl_number_of_message.setStyleSheet(TopNavigationBarContainersStyles.notify_number_of_box_style[1]) self.lbl_number_of_notification = QLabel(self.components_frame) self.lbl_number_of_notification.setGeometry(QRect(60, 5, 31, 26)) self.lbl_number_of_notification.setText("+99") self.lbl_number_of_notification.setAlignment(Qt.AlignCenter) self.lbl_number_of_notification.setObjectName(TopNavigationBarContainersStyles.notify_number_of_box_style[0]) self.lbl_number_of_notification.setStyleSheet(TopNavigationBarContainersStyles.notify_number_of_box_style[1]) main_gridLayout.addWidget(self.components_frame, 0, 0, 1, 1)
def __init__(self, mainWindow, parent=None): """ Constructor @param mainWindow reference to the browser main window @type WebBrowserWindow @param parent reference to the parent widget @type QWidget """ super(NavigationBar, self).__init__(parent) self.setObjectName("navigationbar") self.__mw = mainWindow self.__layout = QHBoxLayout(self) margin = self.style().pixelMetric(QStyle.PM_ToolBarItemMargin, None, self) self.__layout.setContentsMargins(margin, margin, margin, margin) self.__layout.setSpacing(self.style().pixelMetric( QStyle.PM_ToolBarItemSpacing, None, self)) self.setLayout(self.__layout) self.__backButton = E5ToolButton(self) self.__backButton.setObjectName("navigation_back_button") self.__backButton.setToolTip(self.tr("Move one screen backward")) self.__backButton.setToolButtonStyle(Qt.ToolButtonIconOnly) self.__backButton.setFocusPolicy(Qt.NoFocus) self.__backButton.setAutoRaise(True) self.__backButton.setIcon(UI.PixmapCache.getIcon("back.png")) self.__backButton.setEnabled(False) self.__forwardButton = E5ToolButton(self) self.__forwardButton.setObjectName("navigation_forward_button") self.__forwardButton.setToolTip(self.tr("Move one screen forward")) self.__forwardButton.setToolButtonStyle(Qt.ToolButtonIconOnly) self.__forwardButton.setFocusPolicy(Qt.NoFocus) self.__forwardButton.setAutoRaise(True) self.__forwardButton.setIcon(UI.PixmapCache.getIcon("forward.png")) self.__forwardButton.setEnabled(False) self.__backNextLayout = QHBoxLayout() self.__backNextLayout.setContentsMargins(0, 0, 0, 0) self.__backNextLayout.setSpacing(0) self.__backNextLayout.addWidget(self.__backButton) self.__backNextLayout.addWidget(self.__forwardButton) self.__reloadStopButton = ReloadStopButton(self) self.__homeButton = E5ToolButton(self) self.__homeButton.setObjectName("navigation_home_button") self.__homeButton.setToolTip(self.tr("Move to the initial screen")) self.__homeButton.setToolButtonStyle(Qt.ToolButtonIconOnly) self.__homeButton.setFocusPolicy(Qt.NoFocus) self.__homeButton.setAutoRaise(True) self.__homeButton.setIcon(UI.PixmapCache.getIcon("home.png")) self.__exitFullScreenButton = E5ToolButton(self) self.__exitFullScreenButton.setObjectName( "navigation_exitfullscreen_button") self.__exitFullScreenButton.setIcon( UI.PixmapCache.getIcon("windowRestore.png")) self.__exitFullScreenButton.setToolTip(self.tr("Exit Fullscreen")) self.__exitFullScreenButton.setToolButtonStyle(Qt.ToolButtonIconOnly) self.__exitFullScreenButton.setFocusPolicy(Qt.NoFocus) self.__exitFullScreenButton.setAutoRaise(True) self.__exitFullScreenButton.clicked.connect(self.__mw.toggleFullScreen) self.__exitFullScreenButton.setVisible(False) self.__downloadManagerButton = DownloadManagerButton(self) self.__superMenuButton = E5ToolButton(self) self.__superMenuButton.setObjectName("navigation_supermenu_button") self.__superMenuButton.setIcon(UI.PixmapCache.getIcon("superMenu.png")) self.__superMenuButton.setToolTip(self.tr("Main Menu")) self.__superMenuButton.setPopupMode(QToolButton.InstantPopup) self.__superMenuButton.setToolButtonStyle(Qt.ToolButtonIconOnly) self.__superMenuButton.setFocusPolicy(Qt.NoFocus) self.__superMenuButton.setAutoRaise(True) self.__superMenuButton.setShowMenuInside(True) self.__navigationSplitter = QSplitter(self) urlBar = self.__mw.tabWidget().stackedUrlBar() self.__navigationSplitter.addWidget(urlBar) from WebBrowser.WebBrowserWebSearchWidget import ( WebBrowserWebSearchWidget) self.__searchEdit = WebBrowserWebSearchWidget(self.__mw, self) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(2) sizePolicy.setVerticalStretch(0) self.__searchEdit.setSizePolicy(sizePolicy) self.__searchEdit.search.connect(self.__mw.openUrl) self.__navigationSplitter.addWidget(self.__searchEdit) self.__navigationSplitter.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum) self.__navigationSplitter.setCollapsible(0, False) self.__layout.addLayout(self.__backNextLayout) self.__layout.addWidget(self.__reloadStopButton) self.__layout.addWidget(self.__homeButton) self.__layout.addWidget(self.__navigationSplitter) self.__layout.addWidget(self.__downloadManagerButton) self.__layout.addWidget(self.__exitFullScreenButton) self.__layout.addWidget(self.__superMenuButton) self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.__contextMenuRequested) self.__backMenu = QMenu(self) self.__backMenu.triggered.connect(self.__navigationMenuActionTriggered) self.__backButton.setMenu(self.__backMenu) self.__backButton.aboutToShowMenu.connect(self.__showBackMenu) self.__forwardMenu = QMenu(self) self.__forwardMenu.triggered.connect( self.__navigationMenuActionTriggered) self.__forwardButton.setMenu(self.__forwardMenu) self.__forwardButton.aboutToShowMenu.connect(self.__showForwardMenu) self.__backButton.clicked.connect(self.__goBack) self.__backButton.middleClicked.connect(self.__goBackInNewTab) self.__backButton.controlClicked.connect(self.__goBackInNewTab) self.__forwardButton.clicked.connect(self.__goForward) self.__forwardButton.middleClicked.connect(self.__goForwardInNewTab) self.__forwardButton.controlClicked.connect(self.__goForwardInNewTab) self.__reloadStopButton.reloadClicked.connect(self.__reload) self.__reloadStopButton.stopClicked.connect(self.__stopLoad) self.__homeButton.clicked.connect(self.__goHome) self.__homeButton.middleClicked.connect(self.__goHomeInNewTab) self.__homeButton.controlClicked.connect(self.__goHomeInNewTab)
def __init__(self, parent): super(ReferenceDateEdit, self).__init__(parent) self.m_mainLayout = QVBoxLayout() self.m_groupBox = QGroupBox(self) self.m_groupLayout = QVBoxLayout(self.m_groupBox) self.m_tableWidget = QTableWidget(self.m_groupBox) self.m_groupLayout.addWidget(self.m_tableWidget) self.m_inputsLayout = QGridLayout() self.m_typeLabel = QLabel(self.m_groupBox) self.m_inputsLayout.addWidget(self.m_typeLabel, 0, 0, 1, 1) self.m_typeCombo = QComboBox(self.m_groupBox) sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.m_typeCombo.sizePolicy().hasHeightForWidth()) self.m_typeCombo.setSizePolicy(sizePolicy) self.m_inputsLayout.addWidget(self.m_typeCombo, 0, 1, 1, 1) self.m_dateLabel = QLabel(self.m_groupBox) self.m_inputsLayout.addWidget(self.m_dateLabel, 1, 0, 1, 1) self.m_dateEdit = QDateEdit(self.m_groupBox) self.m_dateEdit.setCalendarPopup(True) self.m_inputsLayout.addWidget(self.m_dateEdit, 1, 1, 1, 1) self.m_groupLayout.addLayout(self.m_inputsLayout) self.m_buttonLayout = QHBoxLayout() spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.m_buttonLayout.addItem(spacerItem1) self.m_addButton = QPushButton(self.m_groupBox) self.m_buttonLayout.addWidget(self.m_addButton) self.m_groupLayout.addLayout(self.m_buttonLayout) self.m_mainLayout.addWidget(self.m_groupBox) spacerItem2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.m_mainLayout.addItem(spacerItem2) self.m_typeCombo.addItem("creation") self.m_typeCombo.addItem("publication") self.m_typeCombo.addItem("revision") self.m_typeLabel.setText("Type") self.m_dateLabel.setText("Date") self.m_addButton.setText("Add") self.m_groupBox.setTitle("Reference Date") self.setLayout(self.m_mainLayout) self.m_tableWidget.setColumnCount(3) self.m_tableWidget.setHorizontalHeaderLabels(["Type", "Rev", "Date"]) self.m_tableWidget.horizontalHeader().show() self.m_tableWidget.verticalHeader().hide() self.m_tableWidget.horizontalHeader().setStretchLastSection(True) self.m_tableWidget.setItemDelegateForColumn(2, DateDelegate()) self.m_addButton.pressed.connect(self.addPressed) self.m_tableWidget.model().dataChanged.connect(self.modelDataChanged) self.m_tableWidget.setContextMenuPolicy(Qt.CustomContextMenu) self.m_tableWidget.customContextMenuRequested.connect( self.tableWidgetContextMenu) self.m_tableWidget.setSelectionBehavior(QTableWidget.SelectRows)
def __init__(self, width, height): super().__init__() self.SettingsChanged = False self.setWindowTitle('Settings') self.setGeometry(QRect(round((width - 400) / 2), round((height - 200) / 2), 400, 100)) hBox1 = QHBoxLayout() self.lbPath = QLabel(self) self.lbPath.setText('File path:') self.lnEdit = QLineEdit(self) self.lnEdit.setText(output_path) self.lnEdit.setToolTip('Edit path') self.btnOpen = QPushButton(self) self.btnOpen.setIcon(QIcon(':/folder-icon')) self.btnOpen.setIconSize(QSize(24, 24)) self.btnOpen.setToolTip('Choose folder to save downloaded files') self.btnOpen.clicked.connect(self.onOpenClicked) hBox1.addWidget(self.lbPath, 0) hBox1.addWidget(self.lnEdit, 1) hBox1.addWidget(self.btnOpen, 0) gbStream = QGroupBox(self) gbStream.setTitle('Stream type:') hBox2 = QHBoxLayout() self.btnProgressive = QRadioButton(self) self.btnProgressive.setText('progressive') self.btnProgressive.setToolTip('Streams with both audio and video tracks') self.btnProgressive.toggled.connect(lambda: self.onStreamType(self.btnProgressive.text())) self.btnAdaptive = QRadioButton(self) self.btnAdaptive.setText('adaptive') self.btnAdaptive.setToolTip('Streams with only audio or video track') self.btnAdaptive.toggled.connect(lambda: self.onStreamType(self.btnAdaptive.text())) self.btnAllStream = QRadioButton(self) self.btnAllStream.setText('all') self.btnAllStream.setToolTip('Lists all available downloads') self.btnAllStream.toggled.connect(lambda: self.onStreamType(self.btnAllStream.text())) if stream_type == 'progressive': self.btnProgressive.setChecked(True) elif stream_type == 'adaptive': self.btnAdaptive.setChecked(True) else: self.btnAllStream.setChecked(True) hBox2.addWidget(self.btnProgressive) hBox2.addWidget(self.btnAdaptive) hBox2.addWidget(self.btnAllStream) gbStream.setLayout(hBox2) gbSubtype = QGroupBox(self) gbSubtype.setTitle('Subtype') hBox3 = QHBoxLayout() self.btn3Gpp = QRadioButton(self) self.btn3Gpp.setText('3gpp') self.btn3Gpp.toggled.connect(lambda: self.onSubType(self.btn3Gpp.text())) self.btnMp4 = QRadioButton(self) self.btnMp4.setText('mp4') self.btnMp4.toggled.connect(lambda: self.onSubType(self.btnMp4.text())) self.btnWebm = QRadioButton(self) self.btnWebm.setText('webm') self.btnWebm.toggled.connect(lambda: self.onSubType(self.btnWebm.text())) hBox3.addWidget(self.btn3Gpp) hBox3.addWidget(self.btnMp4) hBox3.addWidget(self.btnWebm) gbSubtype.setLayout(hBox3) if subtype == '3gpp': self.btn3Gpp.setChecked(True) if subtype == 'webm': self.btnWebm.setChecked(True) else: self.btnMp4.setChecked(True) self.chbDlCap = QCheckBox(self) self.chbDlCap.setText('Download a caption if available') self.chbDlCap.setChecked(dl_cap) vBox = QVBoxLayout() vBox.addLayout(hBox1) vBox.addWidget(gbStream) vBox.addWidget(gbSubtype) vBox.addWidget(self.chbDlCap) self.btnBox = QDialogButtonBox(self) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.btnBox.sizePolicy().hasHeightForWidth()) self.btnBox.setSizePolicy(sizePolicy) self.btnBox.setOrientation(Qt.Horizontal) self.btnBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.btnBox.accepted.connect(self.onOk) self.btnBox.rejected.connect(self.onCancel) vBox.addWidget(self.btnBox) self.setLayout(vBox)
def _setupUi(self): self.setWindowTitle(self.app.NAME) self.resize(420, 338) self.centralwidget = QWidget(self) self.verticalLayout = QVBoxLayout(self.centralwidget) self.verticalLayout.setContentsMargins(4, 0, 4, 0) self.verticalLayout.setSpacing(0) hl = QHBoxLayout() label = QLabel(tr("Application Mode:"), self) label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) hl.addWidget(label) self.appModeRadioBox = RadioBox( self, items=[tr("Standard"), tr("Music"), tr("Picture")], spread=False) hl.addWidget(self.appModeRadioBox) self.verticalLayout.addLayout(hl) hl = QHBoxLayout() hl.setAlignment(Qt.AlignLeft) label = QLabel(tr("Scan Type:"), self) label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) hl.addWidget(label) self.scanTypeComboBox = QComboBox(self) self.scanTypeComboBox.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) self.scanTypeComboBox.setMaximumWidth(400) hl.addWidget(self.scanTypeComboBox) self.showPreferencesButton = QPushButton(tr("More Options"), self.centralwidget) self.showPreferencesButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) hl.addWidget(self.showPreferencesButton) self.verticalLayout.addLayout(hl) self.promptLabel = QLabel( tr('Select folders to scan and press "Scan".'), self.centralwidget) self.verticalLayout.addWidget(self.promptLabel) self.treeView = QTreeView(self.centralwidget) self.treeView.setSelectionMode(QAbstractItemView.ExtendedSelection) self.treeView.setSelectionBehavior(QAbstractItemView.SelectRows) self.treeView.setAcceptDrops(True) triggers = (QAbstractItemView.DoubleClicked | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.treeView.setEditTriggers(triggers) self.treeView.setDragDropOverwriteMode(True) self.treeView.setDragDropMode(QAbstractItemView.DropOnly) self.treeView.setUniformRowHeights(True) self.verticalLayout.addWidget(self.treeView) self.horizontalLayout = QHBoxLayout() self.removeFolderButton = QPushButton(self.centralwidget) self.removeFolderButton.setIcon(QIcon(QPixmap(":/minus"))) self.removeFolderButton.setShortcut("Del") self.horizontalLayout.addWidget(self.removeFolderButton) self.addFolderButton = QPushButton(self.centralwidget) self.addFolderButton.setIcon(QIcon(QPixmap(":/plus"))) self.horizontalLayout.addWidget(self.addFolderButton) spacer_item = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacer_item) self.loadResultsButton = QPushButton(self.centralwidget) self.loadResultsButton.setText(tr("Load Results")) self.horizontalLayout.addWidget(self.loadResultsButton) self.scanButton = QPushButton(self.centralwidget) self.scanButton.setText(tr("Scan")) self.scanButton.setDefault(True) self.horizontalLayout.addWidget(self.scanButton) self.verticalLayout.addLayout(self.horizontalLayout) self.setCentralWidget(self.centralwidget) self._setupActions() self._setupMenu() if self.app.prefs.directoriesWindowRect is not None: self.setGeometry(self.app.prefs.directoriesWindowRect) else: move_to_screen_center(self)
def __init__(self): super(SplitData, self).__init__() print("Starting...") self.setWindowTitle("AviaNZ WAV splitter") self.dirName = [] self.dirO = [] self.indirOk = False self.outdirOk = False self.cutLen = 1 # menu bar fileMenu = self.menuBar() #.addMenu("&File") fileMenu.addAction( "About", lambda: SupportClasses_GUI.MessagePopup("a", "About", ".").exec_()) fileMenu.addAction("Quit", lambda: QApplication.quit()) # do we need this? # if platform.system() == 'Darwin': # helpMenu.addAction("About",self.showAbout,"Ctrl+A") # main dock setup area = QWidget() grid = QGridLayout() area.setLayout(grid) self.setCentralWidget(area) ## input label = QLabel("Select input folder with files to split:") self.w_browse = QPushButton(" Browse Folder") self.w_browse.setToolTip( "Warning: files inside subfolders will not be processed!") self.w_browse.setMinimumSize(170, 40) self.w_browse.setIcon(self.style().standardIcon( QStyle.SP_DialogOpenButton)) self.w_browse.setStyleSheet( 'QPushButton {background-color: #c4ccd3; font-weight: bold; font-size:14px; padding: 3px 3px 3px 3px}' ) self.w_browse.clicked.connect(self.browse) self.w_browse.setSizePolicy(QSizePolicy(1, 1)) # area showing the selected folder self.w_dir = QPlainTextEdit() self.w_dir.setFixedHeight(40) self.w_dir.setPlainText('') self.w_dir.setToolTip("The folder being processed") self.w_dir.setSizePolicy(QSizePolicy(3, 1)) ## output labelO = QLabel("Select folder for storing split output:") self.w_browseO = QPushButton(" Browse Folder") self.w_browseO.setMinimumSize(170, 40) self.w_browseO.setIcon(self.style().standardIcon( QStyle.SP_DialogOpenButton)) self.w_browseO.setStyleSheet( 'QPushButton {background-color: #c4ccd3; font-weight: bold; font-size:14px; padding: 3px 3px 3px 3px}' ) self.w_browseO.clicked.connect(self.browseO) self.w_browseO.setSizePolicy(QSizePolicy(1, 1)) # area showing the selected folder self.w_dirO = QPlainTextEdit() self.w_dirO.setFixedHeight(40) self.w_dirO.setPlainText('') self.w_dirO.setToolTip("Split files will be placed here") self.w_dirO.setSizePolicy(QSizePolicy(3, 1)) ## split length self.titleCutLen = QLabel("Set split file duration, in seconds:") self.labelCutLen = QLabel("") self.boxCutLen = QSpinBox() self.boxCutLen.setRange(1, 3600 * 24) self.boxCutLen.setValue(60) ## start self.labelWavs = QLabel("") self.labelWavs.setWordWrap(True) self.labelDatas = QLabel("") self.labelDatas.setWordWrap(True) self.labelDirs = QLabel("") self.labelDirs.setWordWrap(True) self.labelOut = QLabel("") self.labelSum = QLabel("") self.boxCutLen.valueChanged.connect(self.setCutLen) self.setCutLen(self.boxCutLen.value()) self.splitBut = QPushButton(" &Split!") self.splitBut.setFixedHeight(40) self.splitBut.setStyleSheet( 'QPushButton {background-color: #95b5ee; font-weight: bold; font-size:14px} QPushButton:disabled {background-color :#B3BCC4}' ) self.splitBut.clicked.connect(self.split) self.splitBut.setEnabled(False) ## groups inputGroup = QGroupBox("Input") inputGrid = QGridLayout() inputGroup.setLayout(inputGrid) inputGrid.addWidget(label, 0, 0, 1, 4) inputGrid.addWidget(self.w_browse, 1, 0, 1, 1) inputGrid.addWidget(self.w_dir, 1, 1, 1, 3) inputGrid.addWidget(self.labelWavs, 2, 0, 1, 4) inputGrid.addWidget(self.labelDatas, 3, 0, 1, 4) inputGrid.addWidget(self.labelDirs, 4, 0, 1, 4) outputGroup = QGroupBox("Output") outputGrid = QGridLayout() outputGroup.setLayout(outputGrid) outputGrid.addWidget(labelO, 0, 0, 1, 4) outputGrid.addWidget(self.w_browseO, 1, 0, 1, 1) outputGrid.addWidget(self.w_dirO, 1, 1, 1, 3) outputGrid.addWidget(self.titleCutLen, 2, 0, 1, 4) outputGrid.addWidget(self.boxCutLen, 3, 0, 1, 1) outputGrid.addWidget(self.labelCutLen, 3, 1, 1, 3) outputGrid.addWidget(self.labelOut, 4, 0, 1, 4) ## add everything to the main layout grid.addWidget(inputGroup, 0, 0, 2, 4) grid.addWidget(outputGroup, 2, 0, 2, 4) grid.addItem(QSpacerItem(4, 0, 1, 4)) grid.addWidget(self.labelSum, 5, 0, 1, 4) grid.addWidget(self.splitBut, 6, 1, 1, 2) #inputGrid.setSizeConstraint(QLayout.SetFixedSize) #outputGrid.setSizeConstraint(QLayout.SetFixedSize) inputGroup.setSizePolicy(QSizePolicy(1, 5)) inputGroup.setMinimumSize(400, 220) outputGroup.setSizePolicy(QSizePolicy(1, 5)) outputGroup.setMinimumSize(400, 180) grid.setSizeConstraint(QLayout.SetMinimumSize) area.setSizePolicy(QSizePolicy(1, 5)) area.setMinimumSize(400, 400) self.setSizePolicy(QSizePolicy(1, 1)) self.setMinimumSize(200, 400)
def __init__(self, parent=None, wflags=Qt.WindowFlags(), **kw): # default value self._TimerDuration = 10 if 'timer_duration' in kw: self._TimerDuration = kw['timer_duration'] del kw['timer_duration'] # the current button self._ActiveButton = Qt.NoButton # private attributes self.__saveX = 0 self.__saveY = 0 self.__saveModifiers = Qt.NoModifier self.__saveButtons = Qt.NoButton # do special handling of some keywords: # stereo, rw try: stereo = bool(kw['stereo']) except KeyError: stereo = False try: rw = kw['rw'] except KeyError: rw = None # create qt-level widget QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC) if rw: # user-supplied render window self._RenderWindow = rw else: self._RenderWindow = vtk.vtkRenderWindow() WId = self.winId() # Python2 if type(WId).__name__ == 'PyCObject': from ctypes import pythonapi, c_void_p, py_object pythonapi.PyCObject_AsVoidPtr.restype = c_void_p pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object] WId = pythonapi.PyCObject_AsVoidPtr(WId) # Python3 elif type(WId).__name__ == 'PyCapsule': from ctypes import pythonapi, c_void_p, py_object, c_char_p pythonapi.PyCapsule_GetName.restype = c_char_p pythonapi.PyCapsule_GetName.argtypes = [py_object] name = pythonapi.PyCapsule_GetName(WId) pythonapi.PyCapsule_GetPointer.restype = c_void_p pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p] WId = pythonapi.PyCapsule_GetPointer(WId, name) self._RenderWindow.SetWindowInfo(str(int(WId))) if stereo: # stereo mode self._RenderWindow.StereoCapableWindowOn() self._RenderWindow.SetStereoTypeToCrystalEyes() try: self._Iren = kw['iren'] except KeyError: self._Iren = vtk.vtkGenericRenderWindowInteractor() self._Iren.SetRenderWindow(self._RenderWindow) # do all the necessary qt setup self.setAttribute(Qt.WA_OpaquePaintEvent) self.setAttribute(Qt.WA_PaintOnScreen) self.setMouseTracking(True) # get all mouse events self.setFocusPolicy(Qt.WheelFocus) self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self._Timer = QTimer(self) self._Timer.timeout.connect(self.TimerEvent) self._Iren.AddObserver('CreateTimerEvent', self.CreateTimer) self._Iren.AddObserver('DestroyTimerEvent', self.DestroyTimer) self._Iren.GetRenderWindow().AddObserver('CursorChangedEvent', self.CursorChangedEvent) #Create a hidden child widget and connect its destroyed signal to its #parent ``Finalize`` slot. The hidden children will be destroyed before #its parent thus allowing cleanup of VTK elements. self._hidden = QWidget(self) self._hidden.hide() self._hidden.destroyed.connect(self.Finalize)
def __init__(self, *args): super().__init__(BrickletIndustrialDualAnalogInV2, *args) self.analog_in = self.device self.cbe_voltage0 = CallbackEmulator( self.analog_in.get_voltage, 0, self.cb_voltage, self.increase_error_count, pass_arguments_to_result_callback=True) self.cbe_voltage1 = CallbackEmulator( self.analog_in.get_voltage, 1, self.cb_voltage, self.increase_error_count, pass_arguments_to_result_callback=True) self.calibration = None self.sample_rate_label = QLabel('Sample Rate:') self.sample_rate_combo = QComboBox() self.sample_rate_combo.addItem('976 Hz') self.sample_rate_combo.addItem('488 Hz') self.sample_rate_combo.addItem('244 Hz') self.sample_rate_combo.addItem('122 Hz') self.sample_rate_combo.addItem('61 Hz') self.sample_rate_combo.addItem('4 Hz') self.sample_rate_combo.addItem('2 Hz') self.sample_rate_combo.addItem('1 Hz') self.current_voltage = [CurveValueWrapper(), CurveValueWrapper()] # float, V self.calibration_button = QPushButton('Calibration...') self.sample_rate_combo.currentIndexChanged.connect( self.sample_rate_combo_index_changed) self.calibration_button.clicked.connect( self.calibration_button_clicked) plots = [ ('Channel 0', Qt.red, self.current_voltage[0], format_voltage), ('Channel 1', Qt.blue, self.current_voltage[1], format_voltage) ] self.plot_widget = PlotWidget('Voltage [V]', plots, y_resolution=0.001) # Define lines line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) line1 = QFrame() line1.setObjectName("line1") line1.setFrameShape(QFrame.HLine) line1.setFrameShadow(QFrame.Sunken) line2 = QFrame() line2.setObjectName("line2") line2.setFrameShape(QFrame.HLine) line2.setFrameShadow(QFrame.Sunken) # Define channel LED status config widgets self.led_config_ch0_label = QLabel('Channel 0') self.led_config_ch1_label = QLabel('Channel 1') self.led_config_label = QLabel('LED Config:') self.led_status_config_label = QLabel('LED Status Config:') self.led_status_config_ch0_min_label = QLabel('Min:') self.led_status_config_ch0_max_label = QLabel('Max:') self.led_status_config_ch1_min_label = QLabel('Min:') self.led_status_config_ch1_max_label = QLabel('Max:') self.led_config_ch0_combo = QComboBox() self.led_config_ch0_combo.addItem('Off') self.led_config_ch0_combo.addItem('On') self.led_config_ch0_combo.addItem('Show Heartbeat') self.led_config_ch0_combo.addItem('Show Channel Status') self.led_config_ch0_combo.currentIndexChanged.connect( self.led_config_ch0_combo_changed) self.led_config_ch1_combo = QComboBox() self.led_config_ch1_combo.addItem('Off') self.led_config_ch1_combo.addItem('On') self.led_config_ch1_combo.addItem('Show Heartbeat') self.led_config_ch1_combo.addItem('Show Channel Status') self.led_config_ch1_combo.currentIndexChanged.connect( self.led_config_ch1_combo_changed) self.led_status_config_ch0_combo = QComboBox() self.led_status_config_ch0_combo.addItem('Threshold') self.led_status_config_ch0_combo.addItem('Intensity') self.led_status_config_ch0_combo.currentIndexChanged.connect( self.led_status_config_ch0_combo_changed) self.led_status_config_ch1_combo = QComboBox() self.led_status_config_ch1_combo.addItem('Threshold') self.led_status_config_ch1_combo.addItem('Intensity') self.led_status_config_ch1_combo.currentIndexChanged.connect( self.led_status_config_ch1_combo_changed) self.led_status_config_ch0_min_sbox = QSpinBox() self.led_status_config_ch0_min_sbox.setMinimum(-35000) self.led_status_config_ch0_min_sbox.setMaximum(35000) self.led_status_config_ch0_min_sbox.setValue(0) self.led_status_config_ch0_min_sbox.setSingleStep(1) self.led_status_config_ch0_min_sbox.setSuffix(' mV') self.led_status_config_ch0_min_sbox.valueChanged.connect( self.led_status_config_ch0_min_sbox_changed) self.led_status_config_ch0_max_sbox = QSpinBox() self.led_status_config_ch0_max_sbox.setMinimum(-35000) self.led_status_config_ch0_max_sbox.setMaximum(35000) self.led_status_config_ch0_max_sbox.setValue(0) self.led_status_config_ch0_max_sbox.setSingleStep(1) self.led_status_config_ch0_max_sbox.setSuffix(' mV') self.led_status_config_ch0_max_sbox.valueChanged.connect( self.led_status_config_ch0_max_sbox_changed) self.led_status_config_ch1_min_sbox = QSpinBox() self.led_status_config_ch1_min_sbox.setMinimum(-35000) self.led_status_config_ch1_min_sbox.setMaximum(35000) self.led_status_config_ch1_min_sbox.setValue(0) self.led_status_config_ch1_min_sbox.setSingleStep(1) self.led_status_config_ch1_min_sbox.setSuffix(' mV') self.led_status_config_ch1_min_sbox.valueChanged.connect( self.led_status_config_ch1_min_sbox_changed) self.led_status_config_ch1_max_sbox = QSpinBox() self.led_status_config_ch1_max_sbox.setMinimum(-35000) self.led_status_config_ch1_max_sbox.setMaximum(35000) self.led_status_config_ch1_max_sbox.setValue(0) self.led_status_config_ch1_max_sbox.setSingleStep(1) self.led_status_config_ch1_max_sbox.setSuffix(' mV') self.led_status_config_ch1_max_sbox.valueChanged.connect( self.led_status_config_ch1_max_sbox_changed) # Define size policies h_sp = QSizePolicy() h_sp.setHorizontalPolicy(QSizePolicy.Expanding) # Set size policies self.sample_rate_combo.setSizePolicy(h_sp) self.led_config_ch0_combo.setSizePolicy(h_sp) self.led_config_ch1_combo.setSizePolicy(h_sp) self.led_status_config_ch0_combo.setSizePolicy(h_sp) self.led_status_config_ch1_combo.setSizePolicy(h_sp) self.led_status_config_ch0_min_sbox.setSizePolicy(h_sp) self.led_status_config_ch0_max_sbox.setSizePolicy(h_sp) self.led_status_config_ch1_min_sbox.setSizePolicy(h_sp) self.led_status_config_ch1_max_sbox.setSizePolicy(h_sp) # Define layouts hlayout = QHBoxLayout() vlayout = QVBoxLayout() glayout = QGridLayout() layout = QVBoxLayout(self) hlayout_ch0_min_max = QHBoxLayout() hlayout_ch1_min_max = QHBoxLayout() # Populate layouts vlayout.addWidget(self.calibration_button) hlayout.addWidget(self.sample_rate_label) hlayout.addWidget(self.sample_rate_combo) vlayout.addLayout(hlayout) vlayout.addWidget(line1) hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_min_label) hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_min_sbox) hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_max_label) hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_max_sbox) hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_min_label) hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_min_sbox) hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_max_label) hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_max_sbox) glayout.addWidget(self.led_config_ch0_label, 0, 1, 1, 1) # R, C, RS, CS glayout.addWidget(self.led_config_ch1_label, 0, 2, 1, 1) glayout.addWidget(line2, 1, 0, 1, 3) glayout.addWidget(self.led_config_label, 2, 0, 1, 1) glayout.addWidget(self.led_config_ch0_combo, 2, 1, 1, 1) glayout.addWidget(self.led_config_ch1_combo, 2, 2, 1, 1) glayout.addWidget(self.led_status_config_label, 3, 0, 1, 1) glayout.addWidget(self.led_status_config_ch0_combo, 3, 1, 1, 1) glayout.addWidget(self.led_status_config_ch1_combo, 3, 2, 1, 1) glayout.addLayout(hlayout_ch0_min_max, 4, 1, 1, 1) glayout.addLayout(hlayout_ch1_min_max, 4, 2, 1, 1) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(vlayout) layout.addLayout(glayout) self.ui_group_ch_status_ch0 = [ self.led_status_config_ch0_combo, self.led_status_config_ch0_min_sbox, self.led_status_config_ch0_max_sbox ] self.ui_group_ch_status_ch1 = [ self.led_status_config_ch1_combo, self.led_status_config_ch1_min_sbox, self.led_status_config_ch1_max_sbox ]
def createToolBox(self): self.buttonGroup = QButtonGroup() self.buttonGroup.setExclusive(False) self.buttonGroup.buttonClicked[int].connect(self.buttonGroupClicked) layout = QGridLayout() layout.addWidget( self.createCellWidget("Conditional", DiagramItem.Conditional), 0, 0) layout.addWidget(self.createCellWidget("Process", DiagramItem.Step), 0, 1) layout.addWidget(self.createCellWidget("Input/Output", DiagramItem.Io), 1, 0) textButton = QToolButton() textButton.setCheckable(True) self.buttonGroup.addButton(textButton, self.InsertTextButton) textButton.setIcon( QIcon(QPixmap(':/images/textpointer.png').scaled(30, 30))) textButton.setIconSize(QSize(50, 50)) textLayout = QGridLayout() textLayout.addWidget(textButton, 0, 0, Qt.AlignHCenter) textLayout.addWidget(QLabel("Text"), 1, 0, Qt.AlignCenter) textWidget = QWidget() textWidget.setLayout(textLayout) layout.addWidget(textWidget, 1, 1) layout.setRowStretch(3, 10) layout.setColumnStretch(2, 10) itemWidget = QWidget() itemWidget.setLayout(layout) self.backgroundButtonGroup = QButtonGroup() self.backgroundButtonGroup.buttonClicked.connect( self.backgroundButtonGroupClicked) backgroundLayout = QGridLayout() backgroundLayout.addWidget( self.createBackgroundCellWidget("Blue Grid", ':/images/background1.png'), 0, 0) backgroundLayout.addWidget( self.createBackgroundCellWidget("White Grid", ':/images/background2.png'), 0, 1) backgroundLayout.addWidget( self.createBackgroundCellWidget("Gray Grid", ':/images/background3.png'), 1, 0) backgroundLayout.addWidget( self.createBackgroundCellWidget("No Grid", ':/images/background4.png'), 1, 1) backgroundLayout.setRowStretch(2, 10) backgroundLayout.setColumnStretch(2, 10) backgroundWidget = QWidget() backgroundWidget.setLayout(backgroundLayout) self.toolBox = QToolBox() self.toolBox.setSizePolicy( QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Ignored)) self.toolBox.setMinimumWidth(itemWidget.sizeHint().width()) self.toolBox.addItem(itemWidget, "Basic Flowchart Shapes") self.toolBox.addItem(backgroundWidget, "Backgrounds")
mainWindow = QMainWindow() ui = gui_main.Ui_MainWindow() ui.setupUi(mainWindow) # set up map dialog mappedRoute = QDialog(mainWindow) mappedRoute_ui = mapGUI.Ui_Dialog() mappedRoute_ui.setupUi(mappedRoute) #create new map widget in horizontal box layout of map dialog mapWV = WebMapWidget() mappedRoute_ui.mapHBL.addWidget(mapWV) mapWV.setFixedSize(1200, 800) mapWV.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) ui.actionExit.setIcon(app.style().standardIcon(QStyle.SP_DialogCancelButton)) ui.hoursLE.setValidator(QIntValidator()) #========================================== # connect signals #========================================== ui.findLocPB.clicked.connect(runQuery) ui.mapPB.clicked.connect(mapMyRoute) mappedRoute_ui.exportPB.clicked.connect(exportRouteShapefile) #======================================= # run app
def __init__(self, main_window: 'ElectrumWindow') -> None: super().__init__(None) balance_widget = QToolButton() balance_widget.setAutoRaise(True) balance_widget.setPopupMode(QToolButton.MenuButtonPopup) balance_icon_label = QLabel("") balance_icon_label.setPixmap(QPixmap(icon_path("sb_balance.png"))) hbox = QHBoxLayout() hbox.setSpacing(2) hbox.setSizeConstraint(hbox.SetFixedSize) hbox.addWidget(balance_icon_label) self._balance_bsv_label = QLabel("") hbox.addWidget(self._balance_bsv_label) self._balance_equals_label = QLabel("") self._balance_equals_label.setPixmap(QPixmap(icon_path("sb_approximate"))) hbox.addWidget(self._balance_equals_label) self._balance_fiat_label = QLabel("") hbox.addWidget(self._balance_fiat_label) # This is to pad out the text on the RHS so that the menu indicator does not overlay it. hbox.addWidget(QLabel(" ")) balance_widget.setLayout(hbox) balance_widget.addAction(BalancePopupAction(main_window, self, balance_widget)) self._balance_widget = balance_widget self.addPermanentWidget(balance_widget) self._fiat_widget = QWidget() self._fiat_widget.setVisible(False) estimate_icon_label = QLabel("") estimate_icon_label.setPixmap(QPixmap(icon_path("sb_fiat.png"))) hbox = QHBoxLayout() hbox.setSpacing(2) hbox.setSizeConstraint(hbox.SetFixedSize) hbox.addWidget(estimate_icon_label) self._fiat_bsv_label = QLabel("") hbox.addWidget(self._fiat_bsv_label) approximate_icon_label = QLabel("") approximate_icon_label.setPixmap(QPixmap(icon_path("sb_approximate"))) hbox.addWidget(approximate_icon_label) self._fiat_value_label = QLabel("") fm = self._fiat_bsv_label.fontMetrics() width = fm.width("1,000.00 CUR") self._fiat_value_label.setMinimumWidth(width) hbox.addWidget(self._fiat_value_label) self._fiat_widget.setLayout(hbox) self.addPermanentWidget(self._fiat_widget) network_widget = QWidget() network_icon_label = QLabel("") network_icon_label.setPixmap(QPixmap(icon_path("sb_network.png"))) hbox = QHBoxLayout() hbox.setSpacing(2) hbox.addWidget(network_icon_label) self._network_label = QLabel("") sp = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sp.setHorizontalStretch(1) self._network_label.setSizePolicy(sp) hbox.addWidget(self._network_label) network_widget.setLayout(hbox) network_widget.setMinimumWidth(150) self.addPermanentWidget(network_widget) self.search_box = QLineEdit() # self.search_box.textChanged.connect(self.do_search) self.search_box.hide() self.addPermanentWidget(self.search_box)
from PyQt5.QtWidgets import QMainWindow, QLabel, QWidget, QFrame, QSizePolicy from PyQt5.QtGui import QImage, QPixmap from PyQt5.QtCore import Qt, QSize import numpy as np w = QMainWindow(size=QSize(400, 400)) ww = QWidget() w.setCentralWidget(ww) asp = AspectLayout(1.0) ww.setLayout(asp) w.setWindowFlags(Qt.WindowStaysOnTopHint) l = QLabel() l.setScaledContents(True) l.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)) asp.addWidget(l) l.setParent(ww) l.setFrameStyle(QFrame.NoFrame) w.show() def update(): if PINS.title.updated: w.setWindowTitle(PINS.title.get()) global arr arr = PINS.array.get() assert arr.dtype in (float, np.float32, np.uint8), arr.dtype arr = np.ascontiguousarray(arr) if arr.ndim == 1: arr = arr.reshape((len(arr), 1)) if arr.ndim == 3:
def initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) pasteBox = QHBoxLayout() self.textLine = QLineEdit() self.textLine.setToolTip('Current Director/selected File') self.pasteButton = QToolButton() self.pasteButton.setEnabled(False) self.pasteButton.setText('Paste') self.pasteButton.setToolTip( 'Copy file from copy path to current directory/file') self.pasteButton.clicked.connect(self.paste) self.pasteButton.hide() pasteBox.addWidget(self.textLine) pasteBox.addWidget(self.pasteButton) self.copyBox = QFrame() hbox = QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) self.copyLine = QLineEdit() self.copyLine.setToolTip('File path to copy from, when pasting') self.copyButton = QToolButton() self.copyButton.setText('Copy') self.copyButton.setToolTip('Record current file as copy path') self.copyButton.clicked.connect(self.recordCopyPath) hbox.addWidget(self.copyButton) hbox.addWidget(self.copyLine) self.copyBox.setLayout(hbox) self.copyBox.hide() self.model = QFileSystemModel() self.model.setRootPath(QDir.currentPath()) self.model.setFilter(QDir.AllDirs | QDir.NoDot | QDir.Files) self.model.setNameFilterDisables(False) self.model.rootPathChanged.connect(self.folderChanged) self.list = QListView() self.list.setModel(self.model) self.list.resize(640, 480) self.list.clicked[QModelIndex].connect(self.listClicked) self.list.activated.connect(self._getPathActivated) self.list.setAlternatingRowColors(True) self.list.hide() self.table = QTableView() self.table.setModel(self.model) self.table.resize(640, 480) self.table.clicked[QModelIndex].connect(self.listClicked) self.table.activated.connect(self._getPathActivated) self.table.setAlternatingRowColors(True) header = self.table.horizontalHeader() header.setSectionResizeMode(0, QHeaderView.Stretch) header.setSectionResizeMode(1, QHeaderView.ResizeToContents) header.setSectionResizeMode(3, QHeaderView.ResizeToContents) header.swapSections(1, 3) header.setSortIndicator(1, Qt.AscendingOrder) self.table.setSortingEnabled(True) self.table.setColumnHidden(2, True) # type self.table.verticalHeader().setVisible(False) # row count header self.cb = QComboBox() self.cb.currentIndexChanged.connect(self.filterChanged) self.fillCombobox(INFO.PROGRAM_FILTERS_EXTENSIONS) self.cb.setMinimumHeight(30) self.cb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.button2 = QToolButton() self.button2.setText('User') self.button2.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.button2.setMinimumSize(60, 30) self.button2.setToolTip( 'Jump to User directory.\nLong press for Options.') self.button2.clicked.connect(self.onJumpClicked) self.button3 = QToolButton() self.button3.setText('Add Jump') self.button3.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.button3.setMinimumSize(60, 30) self.button3.setToolTip('Add current directory to jump button list') self.button3.clicked.connect(self.onActionClicked) self.settingMenu = QMenu(self) self.button2.setMenu(self.settingMenu) hbox = QHBoxLayout() hbox.addWidget(self.button2) hbox.addWidget(self.button3) hbox.insertStretch(2, stretch=0) hbox.addWidget(self.cb) windowLayout = QVBoxLayout() windowLayout.addLayout(pasteBox) windowLayout.addWidget(self.copyBox) windowLayout.addWidget(self.list) windowLayout.addWidget(self.table) windowLayout.addLayout(hbox) self.setLayout(windowLayout) self.show()
class EUPWidget(QWidget): # static variables font = QFont() font.setBold(True) font.setPointSize(12) size_policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) updateGUI = pyqtSignal() programGUIUpdate = pyqtSignal() robotStateUpdate = pyqtSignal(pp.PandaRobotStatus) tuningGUIUpdate = pyqtSignal(object) tuningAccepted = pyqtSignal(bool, type, str) rangeAccepted = pyqtSignal(bool, type, str) def __init__(self, title='EUP Widget'): super(EUPWidget, self).__init__() self.setWindowTitle(title) # Starting timestamp, for logs name and logging wallclock time self.starting_timestamp = time.time() self.tuning_timeseries = [] # wallclock time of all primitive tunings self.execution_timeseries = [ ] # wallclock time of all primitive executions # Creating the interpreter and loading the program robotless_debug = rospy.get_param( '/robotless_debug') if rospy.has_param( '/robotless_debug') else False self.interpreter = PandaProgramInterpreter( robotless_debug=robotless_debug) if rospy.has_param('/program_path') and rospy.has_param( '/program_name'): program_path = rospy.get_param('/program_path') program_name = rospy.get_param('/program_name') else: program_path = os.path.join(rospkg.RosPack().get_path('panda_pbd'), 'resources') program_name = 'program.pkl' rospy.logwarn( 'Could not find rosparam program_path OR the program_name; loading the example program' ) self.interpreter.load_program( pp.load_program_from_file(program_path, program_name)) # TODO: this reset of history should be an option! it is now here for dealing with old program.pkl self.interpreter.loaded_program.reset_primitives_history() # Randomizing, Range Sliders and TTS options randomize = False if rospy.has_param('/randomize_parameters'): randomize = rospy.get_param('/randomize_parameters') if randomize: rospy.loginfo( 'Going to randomize the primitives parameters... oh dear') self.interpreter.loaded_program.randomize_gui_tunable_primitives() self.range_sliders = False if rospy.has_param('/range_sliders'): self.range_sliders = rospy.get_param('/range_sliders') self.tts_for_primitives = False if rospy.has_param('/tts_for_primitives'): self.tts_for_primitives = rospy.get_param('/tts_for_primitives') self.tts_engine = pyttsx3.init() voices = self.tts_engine.getProperty('voices') self.tts_engine.setProperty('voice', voices[16].id) # American English self.tts_engine.setProperty('volume', 0.8) self.tts_engine.setProperty('rate', 180) # Setting up the state machines self.state_machine = EUPStateMachine.STARTUP self.last_interface_state = None # Thread-pool for the interpreter commands self.threadpool = QThreadPool() rospy.logdebug("Multi-threading with maximum %d threads" % self.threadpool.maxThreadCount()) # Initializing the UI self.initUI() # Subscriber for the interface status self.interface_state_subscriber = rospy.Subscriber( "/primitive_interface_node/interface_state", Int32, self.interface_state_callback) def log_loaded_program(self, need_to_log=True, type_of_primitive=None, name_of_parameter='', partial_log=False): if rospy.has_param('/program_logging_path') and need_to_log: # naming and pathing for the logs program_logging_path = rospy.get_param('/program_logging_path') date = datetime.fromtimestamp( self.starting_timestamp).strftime('%m%d_%H%M') if not os.path.exists(program_logging_path): os.makedirs(program_logging_path) filename = '{}_partial.pkl' if partial_log else '{}.pkl' # log creation and dumping log = {} log['program'] = self.interpreter.loaded_program log['wallclock_time'] = time.time() - self.starting_timestamp log['tuning_timeseries'] = self.tuning_timeseries log['execution_timeseries'] = self.execution_timeseries with open( os.path.join(os.path.expanduser(program_logging_path), filename.format(date)), 'wb') as f: pickle.dump(log, f) rospy.loginfo( 'Current program saved in {}'.format(program_logging_path)) else: rospy.logwarn( 'Could not find rosparam program_logging_path; skipped program logging' ) def interface_state_callback(self, msg): # callback for when interface status msg is received new_interface_status = pp.PandaRobotStatus(msg.data) if self.last_interface_state != new_interface_status: self.last_interface_state = new_interface_status self.updateGUI.emit() def initUI(self): # Create overall layout self.vbox = QVBoxLayout(self) self.vbox.setAlignment(Qt.AlignTop) # Panda Program Widget on top self.panda_program_widget = PandaProgramWidget(self) # Parameter tuning frame self.panda_tuning_widget = PandaTuningWidget( parent=self, range_sliders=self.range_sliders) # Action button & Robot State Widget at the bottom self.low_buttons = QWidget() self.low_buttons_layout = QHBoxLayout(self.low_buttons) self.low_buttons_layout.setAlignment(Qt.AlignCenter) self.robot_state_widget = PandaStateWidget(self) # Making the push button do something useful (call different versions of execute_interpreter_command self.interpreter_command_dict = {} self.interpreter_command_dict['go_to_starting_state'] = [ QExpandingPushButton("Go to\n start state", self), partial(self.execute_interpreter_command, self.interpreter.go_to_starting_state) ] self.interpreter_command_dict['execute_one_step'] = [ QExpandingPushButton("Execute\n one step", self), partial(self.execute_interpreter_command, self.interpreter.execute_one_step) ] self.interpreter_command_dict['revert_one_step'] = [ QExpandingPushButton("Revert\n one step", self), partial(self.execute_interpreter_command, self.interpreter.revert_one_step) ] self.interpreter_command_dict['go_to_current_primitive_preconditions'] = \ [QExpandingPushButton("Recover from error\n on current primitive", self), partial(self.execute_interpreter_command, self.interpreter.go_to_current_primitive_preconditions)] self.interpreter_command_dict['execute_rest_of_program'] = [ QExpandingPushButton("Execute rest\n of program", self), partial(self.execute_interpreter_command, self.interpreter.execute_rest_of_program) ] self.interpreter_command_dict['revert_to_beginning_of_program'] = [ QExpandingPushButton("Revert to\n beginning", self), partial(self.execute_interpreter_command, self.interpreter.revert_to_beginning_of_program) ] # Give the partials a __name__ attribute, used in the execute_interpreter_command function for key, value in self.interpreter_command_dict.items(): value[1].__name__ = key self.low_buttons_layout.addWidget(self.robot_state_widget) self.low_buttons_layout.addWidget( self.interpreter_command_dict['go_to_starting_state'][0]) self.low_buttons_layout.addWidget(QVerticalLine()) self.low_buttons_layout.addWidget( self.interpreter_command_dict['execute_one_step'][0]) self.low_buttons_layout.addWidget( self.interpreter_command_dict['revert_one_step'][0]) self.low_buttons_layout.addWidget(self.interpreter_command_dict[ 'go_to_current_primitive_preconditions'][0]) self.low_buttons_layout.addWidget(QVerticalLine()) self.low_buttons_layout.addWidget( self.interpreter_command_dict['execute_rest_of_program'][0]) self.low_buttons_layout.addWidget( self.interpreter_command_dict['revert_to_beginning_of_program'][0]) # PushButtons events handling for key, value in self.interpreter_command_dict.items(): value[0].clicked.connect(value[1]) value[0].setEnabled(key is 'go_to_starting_state') value[0].setVisible( key is not 'go_to_current_primitive_preconditions') value[0].setFont(EUPWidget.font) # Put everything together self.vbox.addWidget(self.panda_program_widget) self.vbox.addWidget(self.panda_tuning_widget) self.vbox.addWidget(self.low_buttons) # Connect update signals self.tuningAccepted.connect( partial(self.log_loaded_program, partial_log=True) ) # triggers partial logging after parameter tuning self.rangeAccepted.connect( partial(self.log_loaded_program, partial_log=True) ) # triggers partial logging after range update self.updateGUI.connect( self.updatePandaWidgets ) # overall GUI update, triggers the update below self.programGUIUpdate.connect( self.panda_program_widget.updateWidget) # program widget update self.robotStateUpdate.connect( self.robot_state_widget.updateWidget) # robot state widget update self.tuningGUIUpdate.connect( self.panda_tuning_widget.updateWidget) # tuning widget update self.updatePandaWidgets() def updateCurrentPrimitive(self): if self.state_machine == EUPStateMachine.OPERATIONAL: ready_primitive = None try: ready_primitive = self.interpreter.loaded_program.get_nth_primitive( self.interpreter.next_primitive_index) rospy.loginfo('Attempting to tune {}'.format( str(ready_primitive))) except pp.PandaProgramException: pass if ready_primitive is not None: tuning_targets = self.panda_tuning_widget.stacks[type( ready_primitive)].current_tuning range_tuning_targets = self.panda_tuning_widget.stacks[type( ready_primitive)].range_tuning something_tuned = False for key, value in tuning_targets.items(): tuned = self.interpreter.loaded_program.update_nth_primitive_parameter( self.interpreter.next_primitive_index, key, value) rospy.loginfo('Tuning parameter {} of a {} primitive: {}'.format(key, \ type(ready_primitive), \ str(tuned))) self.tuningAccepted.emit(tuned, type(ready_primitive), key) something_tuned = something_tuned or tuned if something_tuned: self.tuning_timeseries.append(time.time()) for key, value in range_tuning_targets.items(): self.interpreter.loaded_program.get_nth_primitive(self.interpreter.next_primitive_index).\ update_parameter_range(key, value) rospy.loginfo('Saving range {} of a {} primitive: {}'.format(key, \ type(ready_primitive), \ str(True))) self.rangeAccepted.emit(True, type(ready_primitive), key) else: rospy.logerr('Are you tuning when you should not?') def updatePandaWidgets(self): rospy.loginfo('{} | {}'.format(self.last_interface_state, self.state_machine)) self.programGUIUpdate.emit() if self.last_interface_state is not None: self.robotStateUpdate.emit(self.last_interface_state) ready_primitive = None try: ready_primitive = self.interpreter.loaded_program.get_nth_primitive( self.interpreter.next_primitive_index) except pp.PandaProgramException: pass self.tuningGUIUpdate.emit(ready_primitive) QApplication.restoreOverrideCursor() if self.last_interface_state == pp.PandaRobotStatus.ERROR or \ self.last_interface_state == pp.PandaRobotStatus.BUSY: for key, value in self.interpreter_command_dict.items(): value[0].setEnabled(False) self.panda_tuning_widget.setEnabled(False) else: if self.state_machine == EUPStateMachine.STARTUP: for key, value in self.interpreter_command_dict.items(): value[0].setEnabled(key is 'go_to_starting_state') self.panda_tuning_widget.setEnabled(False) elif self.state_machine == EUPStateMachine.OPERATIONAL: for key, value in self.interpreter_command_dict.items(): value[0].setEnabled(key is not 'go_to_starting_state') value[0].setVisible( key is not 'go_to_current_primitive_preconditions') self.panda_tuning_widget.setEnabled(True) # last primitive executed, disable execute buttons if self.interpreter.next_primitive_index == self.interpreter.loaded_program.get_program_length( ): self.interpreter_command_dict['execute_one_step'][ 0].setEnabled(False) self.interpreter_command_dict['execute_rest_of_program'][ 0].setEnabled(False) self.interpreter_command_dict['go_to_starting_state'][ 0].setEnabled(True) self.panda_tuning_widget.setEnabled(False) # we are at start, disable revert buttons if self.interpreter.next_primitive_index <= 0: self.interpreter_command_dict['revert_one_step'][ 0].setEnabled(False) self.interpreter_command_dict[ 'revert_to_beginning_of_program'][0].setEnabled(False) elif self.state_machine == EUPStateMachine.STARTUP_BUSY or self.state_machine == EUPStateMachine.BUSY: for key, value in self.interpreter_command_dict.items(): value[0].setEnabled(False) self.panda_tuning_widget.setEnabled(False) elif self.state_machine == EUPStateMachine.STARTUP_ERROR: for key, value in self.interpreter_command_dict.items(): value[0].setEnabled(key is 'go_to_starting_state') self.panda_tuning_widget.setEnabled(False) elif self.state_machine == EUPStateMachine.EXECUTION_ERROR: for key, value in self.interpreter_command_dict.items(): value[0].setEnabled( key is 'go_to_current_primitive_preconditions') value[0].setVisible(key is not 'revert_one_step') if key == 'go_to_current_primitive_preconditions': value[0].setVisible(True) self.panda_tuning_widget.setEnabled(False) elif self.state_machine == EUPStateMachine.REVERTING_ERROR: for key, value in self.interpreter_command_dict.items(): value[0].setEnabled( key is 'go_to_current_primitive_preconditions') value[0].setVisible(key is not 'revert_one_step') if key == 'go_to_current_primitive_preconditions': value[0].setVisible(True) self.panda_tuning_widget.setEnabled(False) def execute_interpreter_command(self, command): # Disable lower buttons for key, value in self.interpreter_command_dict.items(): value[0].setDisabled(True) if (command.__name__ == 'execute_one_step' or \ command.__name__ == 'execute_rest_of_program'): self.updateCurrentPrimitive() if command.__name__ == 'execute_one_step': self.execution_timeseries.append(time.time()) if self.state_machine == EUPStateMachine.STARTUP: self.state_machine = EUPStateMachine.STARTUP_BUSY if self.state_machine == EUPStateMachine.OPERATIONAL: self.state_machine = EUPStateMachine.BUSY worker = Worker( command) # Any other args, kwargs are passed to the run function worker.signals.result.connect(self.reapInterpreterResults) worker.signals.finished.connect(self.announceWorkerDeath) worker.signals.progress.connect(self.actOnWorkerUpdate) QApplication.setOverrideCursor(QCursor( Qt.WaitCursor)) # TODO: Weird bug makes it work only once... self.threadpool.start(worker) def reapInterpreterResults(self, success): rospy.logdebug("Intepreter result: " + str(success)) if self.state_machine == EUPStateMachine.STARTUP_BUSY: self.state_machine = EUPStateMachine.OPERATIONAL if success else EUPStateMachine.STARTUP_ERROR if self.state_machine == EUPStateMachine.BUSY: self.state_machine = EUPStateMachine.OPERATIONAL if success else EUPStateMachine.EXECUTION_ERROR if self.tts_for_primitives and self.interpreter.last_primitive_attempted is not None: if type(self.interpreter.last_primitive_attempted ) is pp.UserSync: sentence = self.interpreter.last_primitive_attempted.result_message[ success] self.tts_engine.say(sentence) self.tts_engine.runAndWait() # if the command failed but the primitive in error is the previous one, I was reverting try: reverting_check = self.interpreter.loaded_program.get_nth_primitive( self.interpreter.next_primitive_index - 1) rospy.logdebug('REVERTING CHECK: {}'.format(reverting_check)) if not success and reverting_check.status == pp.PandaPrimitiveStatus.ERROR: self.state_machine = EUPStateMachine.REVERTING_ERROR except pp.PandaProgramException: pass if self.state_machine == EUPStateMachine.STARTUP_ERROR and success: self.state_machine = EUPStateMachine.STARTUP if (self.state_machine == EUPStateMachine.EXECUTION_ERROR or self.state_machine == EUPStateMachine.REVERTING_ERROR) and success: self.state_machine = EUPStateMachine.OPERATIONAL self.updatePandaWidgets() def announceWorkerDeath(self): rospy.logdebug("RIP Worker!") def actOnWorkerUpdate(self, progress): self.updatePandaWidgets() def sizeHint(self): return QSize(1280, 720) def minimumSizeHint(self): return QSize(800, 600)