class YCrossSection(XCrossSection): """ Y-axis cross section widget parent (QWidget): parent widget position (string): "left" or "right" """ PANEL_ID = ID_YCS OTHER_PANEL_ID = ID_XCS CrossSectionPlotKlass = YCrossSectionPlot def __init__(self, parent=None, position="right", xsection_pos="top"): self.xsection_pos = xsection_pos self.spacer = QSpacerItem(0, 0) super(YCrossSection, self).__init__(parent) self.cs_plot.set_axis_direction("bottom", reverse=position == "left") def setup_widget(self): toolbar = self.toolbar toolbar.setOrientation(Qt.Horizontal) layout = QVBoxLayout() if self.xsection_pos == "top": layout.addSpacerItem(self.spacer) layout.addWidget(toolbar) layout.addWidget(self.cs_plot) if self.xsection_pos == "bottom": layout.addSpacerItem(self.spacer) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) def adjust_height(self, height): self.spacer.changeSize(0, height, QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout().invalidate()
def _setupLEDLayout(self): label_LedPwrLvl = QLabel('Intensity [%]: ', self) hbox_LedPwrLvl = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='LEDPwrLvl', propty_type='sprb') label_LedPwrScaleFactor = QLabel('Power Scale Factor: ', self) hbox_LedPwrScaleFactor = _create_propty_layout( parent=self, prefix=self.scrn_prefix, propty='LEDPwrScaleFactor', propty_type='sprb') label_LedThold = QLabel('Voltage Threshold [V]: ', self) hbox_LedThold = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='LEDThold', propty_type='sprb') flay_LED = QFormLayout() flay_LED.addItem( QSpacerItem(1, 10, QSzPlcy.Fixed, QSzPlcy.MinimumExpanding)) flay_LED.addRow(label_LedPwrLvl, hbox_LedPwrLvl) flay_LED.addRow(label_LedPwrScaleFactor, hbox_LedPwrScaleFactor) flay_LED.addRow(label_LedThold, hbox_LedThold) flay_LED.addItem( QSpacerItem(1, 10, QSzPlcy.Fixed, QSzPlcy.MinimumExpanding)) flay_LED.setLabelAlignment(Qt.AlignRight) flay_LED.setFormAlignment(Qt.AlignCenter) return flay_LED
def _setupUi(self): self.scrn_view = SiriusScrnView(prefix=self._prefix, device=self._scrn) self.cb_scrntype = PyDMEnumComboBox( self, self._scrn_pref.substitute(propty='ScrnType-Sel')) self.l_scrntype = PyDMLabel( self, self._scrn_pref.substitute(propty='ScrnType-Sts')) self.led_scrntype = PyDMLed( self, self._scrn_pref.substitute(propty='ScrnType-Sts'), color_list=[ PyDMLed.LightGreen, PyDMLed.Red, PyDMLed.Red, PyDMLed.Yellow ]) self.led_scrntype.shape = 2 lay = QGridLayout() lay.addWidget( QLabel('<h3>Screen View</h3>', self, alignment=Qt.AlignCenter), 0, 0, 1, 4) lay.addItem(QSpacerItem(20, 20, QSzPlcy.Fixed, QSzPlcy.Fixed), 1, 0) lay.addWidget( QLabel('Select Screen Type: ', self, alignment=Qt.AlignRight), 2, 0) lay.addWidget(self.cb_scrntype, 2, 1) lay.addWidget(self.l_scrntype, 2, 2) lay.addWidget(self.led_scrntype, 2, 3) lay.addItem(QSpacerItem(20, 40, QSzPlcy.Fixed, QSzPlcy.Fixed), 4, 0) lay.addWidget(self.scrn_view, 5, 0, 1, 4) self.setLayout(lay)
def _setupGraphSettingsWidget(self): self._ld_ltfrom = QLabel('Show lifetime from:', self, alignment=Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self._cb_ltfrom = QComboBox() self._cb_ltfrom.addItem('DCCT') self._cb_ltfrom.addItem('BPM') self._cb_ltfrom.currentTextChanged.connect( self._handle_lifetime_type_sel) self._ld_showsmpl = QLabel('Show samples: ', self, alignment=Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self._cb_showsmpl = QCheckBox(self) self._cb_showsmpl.setChecked(True) self._cb_showsmpl.stateChanged.connect(self._handle_samples_visibility) gbox = QGroupBox('Graphs Settings', self) lay = QGridLayout(gbox) lay.addItem(QSpacerItem(1, 1, QSzPlcy.Expanding, QSzPlcy.Minimum), 0, 0) lay.addWidget(self._ld_ltfrom, 0, 1) lay.addWidget(self._cb_ltfrom, 0, 2) lay.addItem(QSpacerItem(1, 1, QSzPlcy.Expanding, QSzPlcy.Minimum), 0, 3) lay.addItem(QSpacerItem(1, 1, QSzPlcy.Minimum, QSzPlcy.Expanding), 1, 1, 1, 2) lay.addWidget(self._ld_showsmpl, 2, 1) lay.addWidget(self._cb_showsmpl, 2, 2) return gbox
def _setupPositionLayout(self): label_AcceptedErr = QLabel('Error Tolerance [mm]: ', self) hbox_AcceptedErr = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='AcceptedErr', propty_type='sprb') label_FluorScrnPos = QLabel('Fluorescent Screen Position [mm]: ', self) hbox_FluorScrnPos = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='FluorScrnPos', propty_type='sprb', cmd={ 'label': 'Get Position', 'pressValue': 1, 'name': 'GetFluorScrnPos' }) label_CalScrnPos = QLabel('Calibration Screen Position [mm]: ', self) hbox_CalScrnPos = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='CalScrnPos', propty_type='sprb', cmd={ 'label': 'Get Position', 'pressValue': 1, 'name': 'GetCalScrnPos' }) label_NoneScrnPos = QLabel('Receded Screen Position [mm]: ', self) hbox_NoneScrnPos = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='NoneScrnPos', propty_type='sprb', cmd={ 'label': 'Get Position', 'pressValue': 1, 'name': 'GetNoneScrnPos' }) flay_pos = QFormLayout() flay_pos.addItem( QSpacerItem(1, 10, QSzPlcy.Fixed, QSzPlcy.MinimumExpanding)) flay_pos.addRow(label_AcceptedErr, hbox_AcceptedErr) flay_pos.addRow(label_FluorScrnPos, hbox_FluorScrnPos) flay_pos.addRow(label_CalScrnPos, hbox_CalScrnPos) flay_pos.addRow(label_NoneScrnPos, hbox_NoneScrnPos) flay_pos.addItem( QSpacerItem(1, 10, QSzPlcy.Fixed, QSzPlcy.MinimumExpanding)) flay_pos.setLabelAlignment(Qt.AlignRight) flay_pos.setFormAlignment(Qt.AlignCenter) return flay_pos
def __init__(self, *args, **kwargs): super(MessageCheckBox, self).__init__(*args, **kwargs) self._checkbox = QCheckBox() # Set layout to include checkbox size = 9 check_layout = QVBoxLayout() check_layout.addItem(QSpacerItem(size, size)) check_layout.addWidget(self._checkbox, 0, Qt.AlignRight) check_layout.addItem(QSpacerItem(size, size)) # Access the Layout of the MessageBox to add the Checkbox layout = self.layout() layout.addLayout(check_layout, 1, 1)
def _setupUi(self): self.tune_settings = QWidget(self) self.tune_settings.setLayout(self._setupTuneSettings()) self.le_tuneconfig.setText(self.tuneconfig_currname) self.chrom_settings = QWidget(self) self.chrom_settings.setLayout(self._setupChromSettings()) self.le_chromconfig.setText(self.chromconfig_currname) self.bt_apply = QPushButton('Apply Settings', self) self.bt_apply.setStyleSheet("""min-width:8em; max-width:8em;""") self.bt_apply.clicked.connect(self._emitSettings) self.bt_apply.setAutoDefault(False) self.bt_apply.setDefault(False) hlay_apply = QHBoxLayout() hlay_apply.addItem( QSpacerItem(20, 60, QSzPlcy.Expanding, QSzPlcy.Ignored)) hlay_apply.addWidget(self.bt_apply) tabs = QTabWidget(self) tabs.addTab(self.tune_settings, 'Tune') tabs.addTab(self.chrom_settings, 'Chromaticity') lay = QVBoxLayout() lay.addWidget(tabs) lay.addLayout(hlay_apply) self.setLayout(lay)
def setup_ui(self): self.vertical_layout = QVBoxLayout(self) self.table_view = QTableView(self) self.table_view.setEditTriggers(QAbstractItemView.DoubleClicked) self.table_view.setProperty("showDropIndicator", False) self.table_view.setDragDropOverwriteMode(False) self.table_view.setSelectionMode(QAbstractItemView.SingleSelection) self.table_view.setSelectionBehavior(QAbstractItemView.SelectRows) self.table_view.setSortingEnabled(False) self.table_view.horizontalHeader().setStretchLastSection(True) self.table_view.verticalHeader().setVisible(False) self.table_view.setColumnWidth(0, 160) self.table_view.setColumnWidth(1, 160) self.table_view.setColumnWidth(2, 160) self.vertical_layout.addWidget(self.table_view) self.add_remove_layout = QHBoxLayout() spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.add_remove_layout.addItem(spacer) self.add_button = QPushButton("Add Curve", self) self.add_remove_layout.addWidget(self.add_button) self.remove_button = QPushButton("Remove Curve", self) self.add_remove_layout.addWidget(self.remove_button) self.vertical_layout.addLayout(self.add_remove_layout) self.button_box = QDialogButtonBox(self) self.button_box.setOrientation(Qt.Horizontal) self.button_box.addButton("Done", QDialogButtonBox.AcceptRole) self.vertical_layout.addWidget(self.button_box) self.button_box.accepted.connect(self.saveChanges) self.button_box.rejected.connect(self.reject) self.setWindowTitle("Waveform Curve Editor")
def _setupUi(self): self.setLayout(QGridLayout()) ld_drive = QLabel( '<h2>Drive Pattern Generators</h2>', self, alignment=Qt.AlignCenter) self.layout().addWidget(ld_drive, 0, 0, 1, 5) for i in range(3): drive = BbBSingleDriveSettingsWidget( prefix=self._prefix, device=self._device, dr_num=i) self.layout().addWidget(drive, 1, 2*i) self.layout().setColumnStretch(1, 2) self.layout().setColumnStretch(3, 2) dev_pref = self._prefix + self._device graph_exct = WfmGraph(self) graph_exct.setAutoRangeY(False) graph_exct.setYRange(-0.01, 1.08) graph_exct.showLegend = True graph_exct.axisColor = QColor('black') graph_exct.add_scatter_curve( ychannel=dev_pref+':DRIVE0_MASK', xchannel=dev_pref+':SRAM_XSC', name='Drive0', color=QColor('red')) graph_exct.add_scatter_curve( ychannel=dev_pref+':DRIVE1_MASK', xchannel=dev_pref+':SRAM_XSC', name='Drive1', color=QColor('magenta'), offset=0.02) graph_exct.add_scatter_curve( ychannel=dev_pref+':DRIVE2_MASK', xchannel=dev_pref+':SRAM_XSC', name='Drive2', color=QColor('orange'), offset=0.04) self.layout().addWidget(graph_exct, 3, 0, 1, 5) self.layout().addItem(QSpacerItem(20, 20), 2, 0)
def __init__(self, methods=None, parent=None): # Initialize parent super().__init__("Functions", parent=parent) self.contents = QWidget() self.layout().addWidget(self.contents) # Create Layout self.contents.setLayout(QHBoxLayout()) # Add two spacers to center our functions without # expanding them self.contents.layout().addItem(QSpacerItem(10, 20)) self.contents.layout().addItem(QSpacerItem(10, 20)) # Add methods methods = methods or list() self.methods = dict() for method in methods: self.add_method(method)
def __init__(self, *args): """Type name: "DXF module".""" super(DxfOutputDialog, self).__init__(*args) # DXF version option version_label = QLabel("DXF version:", self) self.version_option = QComboBox(self) self.version_option.addItems( sorted((f"{name} - {DXF_VERSIONS_MAP[name]}" for name in DXF_VERSIONS), key=lambda v: v.split()[-1])) self.version_option.setCurrentIndex(self.version_option.count() - 1) self.version_option.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) layout = QHBoxLayout() layout.addWidget(version_label) layout.addWidget(self.version_option) self.main_layout.insertLayout(3, layout) # Parts interval self.use_interval = QCheckBox("Parts interval:", self) self.use_interval.setCheckState(Qt.Checked) self.use_interval.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) self.interval_option = QDoubleSpinBox(self) self.interval_option.setValue(10) self.use_interval.stateChanged.connect(self.interval_option.setEnabled) layout = QHBoxLayout() layout.addWidget(self.use_interval) layout.addWidget(self.interval_option) layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Preferred)) self.assembly_layout.insertLayout(2, layout)
def _cameraviewLayout(self): label = QLabel(self.device, self) label.setStyleSheet("""font-weight: bold;max-height:1.29em;""") label.setAlignment(Qt.AlignCenter) self.image_view = _SiriusImageView( parent=self, image_channel=self.scrn_prefix.substitute(propty='ImgData-Mon'), width_channel=self.scrn_prefix.substitute(propty='ImgROIWidth-RB'), offsetx_channel=self.scrn_prefix.substitute( propty='ImgROIOffsetX-RB'), offsety_channel=self.scrn_prefix.substitute( propty='ImgROIOffsetY-RB'), maxwidth_channel=self.scrn_prefix.substitute( propty='ImgMaxWidth-Cte'), maxheight_channel=self.scrn_prefix.substitute( propty='ImgMaxHeight-Cte')) self.image_view.setObjectName('ScrnView') self.image_view.normalizeData = True self.image_view.readingOrder = self.image_view.Clike self.image_view.maxRedrawRate = 15 self.image_view.setStyleSheet(""" #ScrnView{min-width:30em; min-height:24em;}""") self.image_view.failToSaveGrid.connect(self._showFailToSaveGridMsg) self.image_view.receivedData.connect(self._setReceivedDataFlag) lay = QGridLayout() lay.setContentsMargins(0, 0, 0, 0) lay.addWidget(label, 0, 1) lay.addItem(QSpacerItem(40, 2, QSzPlcy.Preferred, QSzPlcy.Fixed), 1, 1) lay.addWidget(self.image_view, 2, 1) return lay
def setupUi(self): self.resize(640, 480) self.verticalLayout = QVBoxLayout(self) self.textEdit = QPlainTextEdit(self) self.closeButton = QPushButton(self) self.copyButton = QPushButton(self) self.verticalLayout.addWidget(self.textEdit) self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setSizeConstraint(QLayout.SetDefaultConstraint) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.horizontalLayout.addWidget(self.copyButton) self.horizontalLayout.addWidget(self.closeButton) self.verticalLayout.addLayout(self.horizontalLayout) self.closeButton.clicked.connect(self.reject) font = QFont(CONFIG['text_view_dialog_font'], CONFIG['text_view_dialog_font_size']) font.setStyleHint(QFont.Monospace) self.textEdit.setFont(font) self.closeButton.setText('Close') self.copyButton.setText('Copy to clipboard') self.textEdit.setPlainText(self.text) self.copyButton.clicked.connect(self.copy_text)
def _auxCommandsWidget(self): self._ld_speedlim = QLabel('Max Phase Speed\n[mm/s]', self) self._sb_speedlim = PyDMSpinbox( self, self.dev_pref.substitute(propty='MaxPhaseSpeed-SP')) self._sb_speedlim.showStepExponent = False self._sb_speedlim.setStyleSheet('max-width:4.5em;') self._lb_speedlim = PyDMLabel( self, self.dev_pref.substitute(propty='MaxPhaseSpeed-RB')) self._ld_homeaxis = QLabel('Do homing', self) self._pb_home = PyDMPushButton(self, label='', icon=qta.icon('mdi.keyboard-return')) self._pb_home.setToolTip('Execute homing for selected axis.') self._pb_home.channel = self.dev_pref.substitute(propty='DevCtrl-Cmd') self._pb_home.pressValue = 10 # Home self._pb_home.setObjectName('Home') self._pb_home.setStyleSheet( '#Home{min-width:30px; max-width:30px; icon-size:25px;}') self._ld_standby = QLabel('Enable Standby Mode', self) self._pb_standby = PyDMPushButton( self, label='', icon=qta.icon('mdi.alpha-a-box-outline')) self._pb_standby.setToolTip( 'Enable standby mode for automatic motion.') self._pb_standby.channel = \ self.dev_pref.substitute(propty='DevCtrl-Cmd') self._pb_standby.pressValue = 5 # Standby self._pb_standby.setObjectName('Standby') self._pb_standby.setStyleSheet( '#Standby{min-width:30px; max-width:30px; icon-size:25px;}') self._ld_lastcomm = QLabel('Last Command', self) self._lb_lastcomm = PyDMLabel( self, self.dev_pref.substitute(propty='LastDevCtrlCmd-Mon')) gbox_auxcmd = QGroupBox('Auxiliary Commands', self) lay_auxcmd = QGridLayout(gbox_auxcmd) lay_auxcmd.addWidget(self._ld_speedlim, 0, 0) lay_auxcmd.addWidget(self._sb_speedlim, 0, 1) lay_auxcmd.addWidget(self._lb_speedlim, 0, 2) lay_auxcmd.addItem(QSpacerItem(1, 10, QSzPlcy.Ignored, QSzPlcy.Fixed), 1, 0) lay_auxcmd.addWidget(self._ld_homeaxis, 2, 0) lay_auxcmd.addWidget(self._pb_home, 2, 1, 1, 2, alignment=Qt.AlignCenter) lay_auxcmd.addWidget(self._ld_standby, 3, 0) lay_auxcmd.addWidget(self._pb_standby, 3, 1, 1, 2, alignment=Qt.AlignCenter) lay_auxcmd.addWidget(self._ld_lastcomm, 4, 0) lay_auxcmd.addWidget(self._lb_lastcomm, 4, 1, 1, 2) return gbox_auxcmd
def setupUi(self): self.resize(340, 320) self.gridLayout = QGridLayout(self) self.dstComboBox = QComboBox(self) self.gridLayout.addWidget(self.dstComboBox, 1, 2, 1, 2) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel | QDialogButtonBox.Ok, self) self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 4) self.loggerList = QListWidget(self) self.loggerList.setDefaultDropAction(Qt.IgnoreAction) self.loggerList.setSelectionMode(QAbstractItemView.MultiSelection) self.gridLayout.addWidget(self.loggerList, 1, 0, 4, 2) self.keepAliveCheckBox = QCheckBox("Keep connections alive", self) self.keepAliveCheckBox.setChecked(True) self.gridLayout.addWidget(self.keepAliveCheckBox, 2, 2, 1, 2) self.srcsLabel = QLabel("All loggers:", self) self.gridLayout.addWidget(self.srcsLabel, 0, 0, 1, 2) self.dstLabel = QLabel("Merge all into:", self) self.gridLayout.addWidget(self.dstLabel, 0, 2, 1, 2) spacerItem = QSpacerItem(20, 169, QSizePolicy.Minimum, QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem, 4, 2, 1, 2) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) self.loggerList.selectionModel().selectionChanged.connect(self.merge_list_changed) self.dstComboBox.currentTextChanged.connect(self.merge_dst_changed) self.ok_button = self.buttonBox.button(QDialogButtonBox.Ok) self.ok_button.setEnabled(False) self.keepAliveCheckBox.setToolTip("If disabled then only the destination connection " "will still be alive after merging.") self.fill_logger_list()
def __init__(self, parent): QWidget.__init__(self, parent) vert_layout = QVBoxLayout() # Type frame type_layout = QHBoxLayout() type_label = QLabel(_("Import as")) type_layout.addWidget(type_label) self.array_btn = array_btn = QRadioButton(_("array")) array_btn.setEnabled(ndarray is not FakeObject) array_btn.setChecked(ndarray is not FakeObject) type_layout.addWidget(array_btn) list_btn = QRadioButton(_("list")) list_btn.setChecked(not array_btn.isChecked()) type_layout.addWidget(list_btn) if pd: self.df_btn = df_btn = QRadioButton(_("DataFrame")) df_btn.setChecked(False) type_layout.addWidget(df_btn) h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) type_layout.addItem(h_spacer) type_frame = QFrame() type_frame.setLayout(type_layout) self._table_view = PreviewTable(self) vert_layout.addWidget(type_frame) vert_layout.addWidget(self._table_view) self.setLayout(vert_layout)
def __init__(self, *args): """Type name: "DXF module".""" super(DxfOutputDialog, self).__init__("DXF", "dxf.png", "The part sketchs will including in the file.", "There is only wire frame will be generated.", *args) # DXF version option. version_label = QLabel("DXF version:", self) self.version_option = QComboBox(self) self.version_option.addItems( sorted((f"{name} - {DXF_VERSIONS_MAP[name]}" for name in DXF_VERSIONS), key=lambda v: v.split()[-1])) self.version_option.setCurrentIndex(self.version_option.count() - 1) self.version_option.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) dxf_version_layout = QHBoxLayout() dxf_version_layout.addWidget(version_label) dxf_version_layout.addWidget(self.version_option) self.main_layout.insertLayout(3, dxf_version_layout) # Parts interval. self.interval_enable = QCheckBox("Parts interval:", self) self.interval_enable.setCheckState(Qt.Checked) self.interval_option = QDoubleSpinBox(self) self.interval_option.setValue(10) self.interval_enable.stateChanged.connect( self.interval_option.setEnabled) dxf_interval_layout = QHBoxLayout() dxf_interval_layout.addWidget(self.interval_enable) dxf_interval_layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) dxf_interval_layout.addWidget(self.interval_option) self.assembly_layout.insertLayout(2, dxf_interval_layout)
def _set_items(self, views: PANEL_VIEW_CLASS = None): """ Clear all items on the panel and then add items from argument 'views'. Args: views: Returns: """ if views is None: return self.widgets_dic: Dict[str, QWidget] = {} self.layout().setContentsMargins(0, 0, 0, 0) for v in views: if isinstance(v, dict): self.add_widget(v, self.layout()) elif isinstance(v[0], str): self.add_widget(v, self.layout()) elif isinstance(v[0], (list, tuple, dict)): sub_layout = None if self.layout_dir == 'v': sub_layout = QHBoxLayout() self.layout().addLayout(sub_layout) else: sub_layout = QVBoxLayout() self.layout().addLayout(sub_layout) for subv in v: self.add_widget(subv, sub_layout) if self.with_aux_spacer: if self.layout_dir == 'h': sub_layout.addItem( QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)) else: sub_layout.addItem( QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) if self.with_spacer: if self.layout_dir == 'v': self.layout().addItem( QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)) else: self.layout().addItem( QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
def _setupUi(self): ld_exct_masks = QLabel('<h3>Excitation Masks</h3>', self, alignment=Qt.AlignCenter) ld_spec_masks = QLabel('<h3>Spectrum Averaging Masks</h3>', self, alignment=Qt.AlignCenter) graph_exct = WfmGraph(self) graph_exct.setAutoRangeY(False) graph_exct.setYRange(-0.01, 1.08) graph_exct.showLegend = True graph_exct.axisColor = QColor('black') graph_exct.add_scatter_curve(ychannel=self.dev_pref + ':FB_MASK', xchannel=self.dev_pref + ':SRAM_XSC', name='Feedback', color=QColor('blue')) graph_exct.add_scatter_curve(ychannel=self.dev_pref + ':CF_MASK', xchannel=self.dev_pref + ':SRAM_XSC', name='Alternate', color=QColor('green'), offset=0.02) graph_exct.add_scatter_curve(ychannel=self.dev_pref + ':DRIVE0_MASK', xchannel=self.dev_pref + ':SRAM_XSC', name='Drive0', color=QColor('red'), offset=0.04) graph_exct.add_scatter_curve(ychannel=self.dev_pref + ':DRIVE1_MASK', xchannel=self.dev_pref + ':SRAM_XSC', name='Drive1', color=QColor('magenta'), offset=0.06) graph_exct.add_scatter_curve(ychannel=self.dev_pref + ':DRIVE2_MASK', xchannel=self.dev_pref + ':SRAM_XSC', name='Drive2', color=QColor('orange'), offset=0.08) graph_spec = WfmGraph(self) graph_spec.setAutoRangeY(False) graph_spec.setYRange(-0.01, 1.08) graph_spec.showLegend = True graph_spec.axisColor = QColor('black') graph_spec.add_scatter_curve(ychannel=self.dev_pref + ':SRAM_ACQ_MASK', xchannel=self.dev_pref + ':SRAM_XSC', name='SRAM', color=QColor('red')) graph_spec.add_scatter_curve(ychannel=self.dev_pref + ':BRAM_ACQ_MASK', xchannel=self.dev_pref + ':BRAM_XSC', name='BRAM', color=QColor('blue'), offset=0.02) lay = QGridLayout(self) lay.addWidget(ld_exct_masks, 0, 0) lay.addWidget(graph_exct, 1, 0) lay.addItem(QSpacerItem(20, 20), 2, 0) lay.addWidget(ld_spec_masks, 3, 0) lay.addWidget(graph_spec, 4, 0)
def _setupUi(self): self.lb_circtin = PyDMLabel( self, self.prefix+self.chs['TL Sts']['Circ TIn']) self.lb_circtin.showUnits = True self.lb_circtin.setStyleSheet('qproperty-alignment: AlignLeft;') self.lb_circtout = PyDMLabel( self, self.prefix+self.chs['TL Sts']['Circ TOut']) self.lb_circtout.showUnits = True self.lb_circtout.setStyleSheet('qproperty-alignment: AlignLeft;') self.led_circarc = SiriusLedAlert( self, self.prefix+self.chs['TL Sts']['Circ Arc']) if self.section == 'SI': self.led_loadarc = SiriusLedAlert( self, self.prefix+self.chs['TL Sts']['Load Arc']) self.led_circflwrt = SiriusLedAlert( self, self.prefix+self.chs['TL Sts']['Circ FlwRt']) self.led_loadflwrt = SiriusLedAlert( self, self.prefix+self.chs['TL Sts']['Load FlwRt']) self.led_circintlkop = SiriusLedAlert( self, self.prefix+self.chs['TL Sts']['Circ Intlk']) lay = QFormLayout(self) lay.setLabelAlignment(Qt.AlignRight) lay.addRow(QLabel('<h4>Transm. Line - Detailed Status</h4>')) lay.addItem(QSpacerItem(0, 10, QSzPlcy.Ignored, QSzPlcy.Fixed)) lay.addRow('Circulator T In: ', self.lb_circtin) lay.addRow('Circulator T Out: ', self.lb_circtout) lay.addItem(QSpacerItem(0, 10, QSzPlcy.Ignored, QSzPlcy.Fixed)) lay.addRow('Circulator Arc Detector: ', self.led_circarc) if self.section == 'SI': lay.addRow('Load Arc Detector: ', self.led_loadarc) lay.addRow('Circulator Flow: ', self.led_circflwrt) lay.addRow('Load Flow: ', self.led_loadflwrt) lay.addRow('Circulator Intlk: ', self.led_circintlkop) self.setStyleSheet(""" PyDMLabel{ qproperty-alignment: AlignLeft; } QLed{ max-width: 1.29em; } .QLabel{ max-height:2em; qproperty-alignment: AlignRight; }""")
def _setupImageCalibLayout(self): cam_prefix = SiriusPVName(self.scrn_prefix).substitute(dev='ScrnCam') label_ImgScaleFactorX = QLabel('Scale Factor X: ', self) hbox_ImgScaleFactorX = _create_propty_layout(parent=self, prefix=cam_prefix, propty='ScaleFactorX', propty_type='sprb') label_ImgScaleFactorY = QLabel('Scale Factor Y: ', self) hbox_ImgScaleFactorY = _create_propty_layout(parent=self, prefix=cam_prefix, propty='ScaleFactorY', propty_type='sprb') label_ImgCenterOffsetX = QLabel('Center Offset X [pixels]: ', self) hbox_ImgCenterOffsetX = _create_propty_layout(parent=self, prefix=cam_prefix, propty='CenterOffsetX', propty_type='sprb') label_ImgCenterOffsetY = QLabel('Center Offset Y [pixels]: ', self) hbox_ImgCenterOffsetY = _create_propty_layout(parent=self, prefix=cam_prefix, propty='CenterOffsetY', propty_type='sprb') label_ImgThetaOffset = QLabel('Theta Offset [pixels]: ', self) hbox_ImgThetaOffset = _create_propty_layout(parent=self, prefix=cam_prefix, propty='ThetaOffset', propty_type='sprb') flay_Img = QFormLayout() flay_Img.addItem( QSpacerItem(1, 10, QSzPlcy.Fixed, QSzPlcy.MinimumExpanding)) flay_Img.addRow(label_ImgScaleFactorX, hbox_ImgScaleFactorX) flay_Img.addRow(label_ImgScaleFactorY, hbox_ImgScaleFactorY) flay_Img.addRow(label_ImgCenterOffsetX, hbox_ImgCenterOffsetX) flay_Img.addRow(label_ImgCenterOffsetY, hbox_ImgCenterOffsetY) flay_Img.addRow(label_ImgThetaOffset, hbox_ImgThetaOffset) flay_Img.addItem( QSpacerItem(1, 10, QSzPlcy.Fixed, QSzPlcy.MinimumExpanding)) flay_Img.setLabelAlignment(Qt.AlignRight) flay_Img.setFormAlignment(Qt.AlignCenter) return flay_Img
def __init__(self, parent): super(GUIConfigFrame, self).__init__(parent) self.widget_layout = QVBoxLayout(self) self.setLayout(self.widget_layout) self.gui_conf_label = QLabel(self) self.gui_conf_label.setText("GUI server configuration") self.widget_layout.addWidget(self.gui_conf_label) self.desc_label = QLabel(self) self.desc_label.setWordWrap(True) self.desc_label.setText( "QtPyBotnet GUI if fully remote. This means that you can connect to C2 server and " "manage bots wherever you are. To authenticate when connecting to GUI server use the " "key below.") self.widget_layout.addWidget(self.desc_label) self.gui_config = QWidget(self) self.gui_config_layout = QFormLayout(self.gui_config) self.widget_layout.addWidget(self.gui_config) self.gui_ip_label = QLabel(self.gui_config) self.gui_ip_label.setObjectName("gui_ip_label") self.gui_ip_label.setText("GUI IP Address") self.gui_ip_combo = QComboBox(self.gui_config) self.gui_config_layout.addRow(self.gui_ip_label, self.gui_ip_combo) self.gui_port_label = QLabel(self.gui_config) self.gui_port_label.setObjectName("gui_port_label") self.gui_port_label.setText("GUI Port") self.gui_port_edit = QSpinBox(self.gui_config) self.gui_port_edit.setObjectName("gui_port_spin") self.gui_port_edit.setRange(1024, 65535) self.gui_port_edit.setValue(15692) self.gui_config_layout.addRow(self.gui_port_label, self.gui_port_edit) self.gui_key_label = QLabel(self.gui_config) self.gui_key_label.setObjectName("gui_key_label") self.gui_key_label.setText("GUI encryption key") self.gui_key_edit = QLineEdit(self.gui_config) self.gui_key_edit.setObjectName("gui_key_edit") self.gui_key_edit.setReadOnly(True) self.gui_config_layout.addRow(self.gui_key_label, self.gui_key_edit) self.gmaps_key_label = QLabel(self.gui_config) self.gmaps_key_label.setObjectName("gmaps_key_label") self.gmaps_key_label.setText("Google Maps API key") self.gmap_key_edit = QLineEdit(self.gui_config) self.gmap_key_edit.setObjectName("gmap_key_edit") self.gui_config_layout.addRow(self.gmaps_key_label, self.gmap_key_edit) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.widget_layout.addItem(spacerItem)
def setupUi(self): self.resize(350, 280) self.gridLayout = QGridLayout(self) self.levelNameLabel = QLabel("Level name", self) self.gridLayout.addWidget(self.levelNameLabel, 0, 0) self.levelNameLine = QLineEdit(self) self.gridLayout.addWidget(self.levelNameLine, 1, 0, 1, 0) self.groupBox = QGroupBox("Light mode", self) self.gridLayout.addWidget(self.groupBox, 2, 0) self.groupBoxDark = QGroupBox("Dark mode", self) self.gridLayout.addWidget(self.groupBoxDark, 2, 1) self.formLayout = QFormLayout(self.groupBox) self.groupBox.setLayout(self.formLayout) self.fgColorPreview = QLineEdit(self) self.formLayout.addRow("Foreground", self.fgColorPreview) self.bgColorPreview = QLineEdit(self) self.formLayout.addRow("Background", self.bgColorPreview) self.boldCheckBox = QCheckBox(self.groupBox) self.formLayout.addRow("Bold", self.boldCheckBox) self.italicCheckBox = QCheckBox(self.groupBox) self.formLayout.addRow("Italic", self.italicCheckBox) self.underlineCheckBox = QCheckBox(self.groupBox) self.formLayout.addRow("Underline", self.underlineCheckBox) self.formLayoutDark = QFormLayout(self.groupBoxDark) self.groupBoxDark.setLayout(self.formLayoutDark) self.fgColorPreviewDark = QLineEdit(self) self.formLayoutDark.addRow("Foreground", self.fgColorPreviewDark) self.bgColorPreviewDark = QLineEdit(self) self.formLayoutDark.addRow("Background", self.bgColorPreviewDark) self.boldCheckBoxDark = QCheckBox(self.groupBoxDark) self.formLayoutDark.addRow("Bold", self.boldCheckBoxDark) self.italicCheckBoxDark = QCheckBox(self.groupBox) self.formLayoutDark.addRow("Italic", self.italicCheckBoxDark) self.underlineCheckBoxDark = QCheckBox(self.groupBox) self.formLayoutDark.addRow("Underline", self.underlineCheckBoxDark) self.spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.gridLayout.addItem(self.spacer, 3, 0, 1, 2) self.previewLabel = QLabel("Preview", self) self.gridLayout.addWidget(self.previewLabel, 4, 0, 1, 2) self.previewLine = QLineEdit(self) self.gridLayout.addWidget(self.previewLine, 5, 0) self.previewLineDark = QLineEdit(self) self.gridLayout.addWidget(self.previewLineDark, 5, 1) buttons = QDialogButtonBox.Reset | QDialogButtonBox.Save | QDialogButtonBox.Cancel self.buttonBox = QDialogButtonBox(buttons, self) self.resetButton = self.buttonBox.button(QDialogButtonBox.Reset) self.gridLayout.addWidget(self.buttonBox, 6, 0, 1, 2) self.setup_widget_attributes() self.setup_widget_connections()
def __init__(self, vpoints: Sequence[VPoint], vlinks: Sequence[VLink], path: _Paths, slider_path: _SliderPaths, monochrome: bool, parent: QWidget): super(AnimateDialog, self).__init__(parent) self.setWindowTitle("Vector Animation") self.setWindowFlags(self.windowFlags() | Qt.WindowMaximizeButtonHint & ~Qt.WindowContextHelpButtonHint) self.setMinimumSize(800, 600) self.setModal(True) main_layout = QVBoxLayout(self) self.canvas = _DynamicCanvas(vpoints, vlinks, path, slider_path, self) self.canvas.set_monochrome_mode(monochrome) self.canvas.update_pos.connect(self.__set_pos) layout = QHBoxLayout(self) pt_option = QComboBox(self) pt_option.addItems([f"P{p}" for p in range(len(vpoints))]) layout.addWidget(pt_option) value_label = QLabel(self) @Slot(int) def show_values(ind: int): vel, vel_deg = self.canvas.get_vel(ind) acc, acc_deg = self.canvas.get_acc(ind) value_label.setText( f"Velocity: {vel:.04f} ({vel_deg:.04f}deg) | " f"Acceleration: {acc:.04f} ({acc_deg:.04f}deg)") pt_option.currentIndexChanged.connect(show_values) layout.addWidget(value_label) self.pos_label = QLabel(self) layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) layout.addWidget(self.pos_label) main_layout.addLayout(layout) main_layout.addWidget(self.canvas) layout = QHBoxLayout(self) self.play = QPushButton(QIcon(QPixmap(":/icons/play.png")), "", self) self.play.setCheckable(True) self.play.clicked.connect(self.__play) layout.addWidget(self.play) self.slider = QSlider(Qt.Horizontal, self) self.slider.setMaximum(max(len(p) for p in path) - 1) self.slider.valueChanged.connect(self.canvas.set_index) layout.addWidget(self.slider) layout.addWidget(QLabel("Total times:", self)) factor = QDoubleSpinBox(self) factor.valueChanged.connect(self.canvas.set_factor) factor.setSuffix('s') factor.setRange(0.01, 999999) factor.setValue(10) layout.addWidget(factor) main_layout.addLayout(layout) self.timer = QTimer() self.timer.setInterval(10) self.timer.timeout.connect(self.__move_ind)
def _setupHVPSWidget(self): self._ld_hvpsswtsel = QLabel('Switch', self) self._bt_hvpsswtsel = PyDMStateButton( self, self.prefix + self.dev_pref + ':EG-HVPS:switch') self._ld_hvpsswtsts = QLabel('Status', self) self._led_hvpsswtsts = SiriusLedState( self, self.prefix + self.dev_pref + ':EG-HVPS:swstatus') self._ld_hvpsvoltsp = QLabel('Voltage SP [kV]', self) self._sb_hvpsvoltsp = SiriusSpinbox( self, self.prefix + self.dev_pref + ':EG-HVPS:voltoutsoft') self._sb_hvpsvoltsp.showStepExponent = False self._ld_hvpsvoltrb = QLabel('Voltage RB [kV]', self) self._lb_hvpsvoltrb = PyDMLabel( self, self.prefix + self.dev_pref + ':EG-HVPS:voltinsoft') self._ld_hvpsenblsel = QLabel('Enable') self._bt_hvpsenblsel = PyDMStateButton( self, self.prefix + self.dev_pref + ':EG-HVPS:enable') self._ld_hvpsenblsts = QLabel('Status') self._led_hvpsenblsts = SiriusLedState( self, self.prefix + self.dev_pref + ':EG-HVPS:enstatus') self._ld_hvpscurrsp = QLabel('Current SP [mA]') self._sb_hvpscurrsp = SiriusSpinbox( self, self.prefix + self.dev_pref + ':EG-HVPS:currentoutsoft') self._sb_hvpscurrsp.showStepExponent = False self._ld_hvpscurrrb = QLabel('Current RB [mA]') self._lb_hvpscurrrb = PyDMLabel( self, self.prefix + self.dev_pref + ':EG-HVPS:currentinsoft') wid = QGroupBox('High Voltage Power Supply', self) lay = QGridLayout(wid) lay.addWidget(self._ld_hvpsswtsel, 0, 0) lay.addWidget(self._bt_hvpsswtsel, 1, 0) lay.addWidget(self._ld_hvpsswtsts, 0, 1) lay.addWidget(self._led_hvpsswtsts, 1, 1) lay.addWidget(self._ld_hvpsvoltsp, 0, 2) lay.addWidget(self._sb_hvpsvoltsp, 1, 2) lay.addWidget(self._ld_hvpsvoltrb, 0, 3) lay.addWidget(self._lb_hvpsvoltrb, 1, 3) lay.addItem(QSpacerItem(1, 15, QSzPlcy.Ignored, QSzPlcy.Fixed), 2, 0) lay.addWidget(self._ld_hvpsenblsel, 3, 0) lay.addWidget(self._bt_hvpsenblsel, 4, 0) lay.addWidget(self._ld_hvpsenblsts, 3, 1) lay.addWidget(self._led_hvpsenblsts, 4, 1) lay.addWidget(self._ld_hvpscurrsp, 3, 2) lay.addWidget(self._sb_hvpscurrsp, 4, 2) lay.addWidget(self._ld_hvpscurrrb, 3, 3) lay.addWidget(self._lb_hvpscurrrb, 4, 3) return wid
def __init__(self, parent=None): """Display a dialog that shows application information.""" super(AboutDialog, self).__init__(parent) self.setWindowTitle('About') self.resize(175, 100) self.layout = QVBoxLayout() title = QLabel('OpenBurn') title.setStyleSheet("font-weight: bold;") title.setAlignment(Qt.AlignCenter) self.layout.addWidget(title) version = QLabel('Version ' + ob.__version__) self.layout.addWidget(version) github = QLabel('<a href=https://github.com/tuxxi/OpenBurn>GitHub</a>') github.setTextFormat(Qt.RichText) github.setTextInteractionFlags(Qt.TextBrowserInteraction) github.setOpenExternalLinks(True) self.layout.addWidget(github) # author self.layout.addSpacerItem(QSpacerItem(10, 10)) auth = QLabel(self.tr("Author:")) auth.setStyleSheet("font-weight: bold;") auth.setAlignment(Qt.AlignCenter) self.layout.addWidget(auth) author = f"{ob.__author__}: {ob.__author_email__}" self.layout.addWidget(QLabel(author)) # special thanks self.layout.addSpacerItem(QSpacerItem(10, 10)) thx = QLabel("Special Thanks:") thx.setStyleSheet("font-weight: bold;") thx.setAlignment(Qt.AlignCenter) self.layout.addWidget(thx) for thanks in ob.__special_thanks__: self.layout.addWidget(QLabel(thanks)) self.setLayout(self.layout)
def __init__(self): """Create our windgets. """ super().__init__() layout = QVBoxLayout() # For our "uptime" timer. self.start_time = time.time() # Label for our progress bar. bar_label = QLabel("Draw Time:") layout.addWidget(bar_label) # Progress bar is not used for "progress", it's just a bar graph to show # the "draw time", the duration of the "UpdateRequest" event. bar = QProgressBar() bar.setRange(0, 100) bar.setValue(50) bar.setFormat("%vms") layout.addWidget(bar) self.bar = bar # We let the user set the "slow event" threshold. self.thresh_ms = self.THRESH_DEFAULT self.thresh_combo = QComboBox() self.thresh_combo.addItems(self.THRESH_OPTIONS) self.thresh_combo.activated[str].connect(self._change_thresh) self.thresh_combo.setCurrentText(str(self.thresh_ms)) combo_layout = QHBoxLayout() combo_layout.addWidget(QLabel("Show Events Slower Than:")) combo_layout.addWidget(self.thresh_combo) combo_layout.addWidget(QLabel("milliseconds")) combo_layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) ) layout.addLayout(combo_layout) # We log slow events to this window. self.log = TextLog() layout.addWidget(self.log) # Uptime label. To indicate if the widget is getting updated. label = QLabel('') layout.addWidget(label) self.timer_label = label self.setLayout(layout) # Update us with a timer. self.timer = QTimer(self) self.timer.timeout.connect(self.update) self.timer.setInterval(self.UPDATE_MS) self.timer.start()
def __init__(self, parent): super(C2ConfigFrame, self).__init__(parent) self.widget_layout = QVBoxLayout(self) self.setLayout(self.widget_layout) self.c2_conf_label = QLabel(self) self.c2_conf_label.setText("C2 server configuration") self.widget_layout.addWidget(self.c2_conf_label) self.desc_label = QLabel(self) self.desc_label.setWordWrap(True) self.desc_label.setText( "Make sure that port you use is opened and IP address is " "valid. To balance server load, select amount of threads to use. Set 0 to use all " "available system cores.") self.widget_layout.addWidget(self.desc_label) self.ip_config = QWidget(self) self.ip_config_layout = QFormLayout(self.ip_config) self.widget_layout.addWidget(self.ip_config) self.c2_ip_label = QLabel(self.ip_config) self.c2_ip_label.setText("C2 IP Address") self.c2_ip_combo = QComboBox(self.ip_config) self.ip_config_layout.addRow(self.c2_ip_label, self.c2_ip_combo) self.port_label = QLabel(self.ip_config) self.port_label.setText("C2 Port") self.port_edit = QSpinBox(self.ip_config) self.port_edit.setRange(1024, 65535) self.port_edit.setValue(8192) self.ip_config_layout.addRow(self.port_label, self.port_edit) self.threads_label = QLabel(self.ip_config) self.threads_label.setText("C2 handler threads") self.threads_edit = QSpinBox(self.ip_config) self.threads_edit.setRange(0, 256) self.ip_config_layout.addRow(self.threads_label, self.threads_edit) self.c2_key_label = QLabel(self.ip_config) self.c2_key_label.setText("C2 encryption key") self.c2_key_edit = QLineEdit(self.ip_config) self.c2_key_edit.setReadOnly(True) self.c2_key_edit.setText(generate_key().decode()) self.ip_config_layout.addRow(self.c2_key_label, self.c2_key_edit) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.widget_layout.addItem(spacerItem)
def add_row(self, widget): """Add widget to row""" item = widget.item line, col, span = self.items_pos[item.item] if col > 0: self.layout.addItem(QSpacerItem(20, 1), line, col * 3 - 1) widget.place_on_grid(self.layout, line, col * 3, col * 3 + 1, 1, 3 * span - 2) try: widget.get() except Exception: print("Error building item :", item.item._name) raise
def __init__(self, model, *args, **kwargs): super().__init__(*args, **kwargs) self.model = model self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) # A "Back" button self._back_button = QPushButton("Back") self._back_button.setEnabled(False) self.layout().addWidget(self._back_button) self._back_button.clicked.connect(model.go_back) # Hook up model Events to Qt Slots. self.model.events.enter.connect(self.on_enter) self.model.events.go_back.connect(self.on_go_back) self.model.events.run_search_ready.connect(self.on_run_search_ready) self.model.events.run_search_cleared.connect( self.on_run_search_cleared) self._selector_widgets = [] # QComboBoxes self._run_search_widgets = [ ] # The SearchInput and SearchOutput widgets self._vspacer = QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Minimum) run_search = model.run_search if run_search: # The root catalog contains Runs, so immediately display Run Search # input and output. self._initialize_run_search(run_search.search_input, run_search.search_results) # No need to have a "Back" button in this case self._back_button.setVisible(False) else: # The root catalog is a catalog-of-catalogs, so display a combo # box. self._initialize_selector(list(model.current_catalog))