def _initialize(self): ## self.paramTPerm = self.field("paramTPerm") self.tabs.clear() self.total_answers = 0 self.radioGroups = {} filas = self.paramNPerm for x in range(filas): mygroupbox = QScrollArea() mygroupbox.setWidget(QWidget()) mygroupbox.setWidgetResizable(True) myform = QHBoxLayout(mygroupbox.widget()) cols = self.paramNCols.split(',') ansID = 0 radioGroupList = {} for col in cols: mygroupboxCol = QGroupBox() myformCol = QFormLayout() mygroupboxCol.setLayout(myformCol) for y in range(int(col)): ansID += 1 radioGroupList[ansID] = QButtonGroup() layoutRow = QHBoxLayout() for j in range(self.paramNAlts): myradio = QRadioButton(chr(97+j).upper()) layoutRow.addWidget(myradio) radioGroupList[ansID].addButton(myradio) self.total_answers += 1 myformCol.addRow(str(ansID), layoutRow) myform.addWidget(mygroupboxCol) self.radioGroups[chr(97+x).upper()] = radioGroupList self.tabs.addTab(mygroupbox, _('Model ') + chr(97+x).upper())
def __init__(self, **kwargs): super().__init__(**kwargs) self.setLayout(QVBoxLayout()) self.layout().setAlignment(Qt.AlignTop) # Startup layout self.layoutGroup = QGroupBox(self) self.layoutGroup.setTitle('Startup layout') self.layoutGroup.setLayout(QVBoxLayout()) self.layout().addWidget(self.layoutGroup) self.startupDialogCheck = QCheckBox(self.layoutGroup) self.startupDialogCheck.setText('Use startup dialog') self.layoutGroup.layout().addWidget(self.startupDialogCheck) self.layoutCombo = QComboBox(self.layoutGroup) self.layoutCombo.addItems([lay.NAME for lay in layouts.get_layouts()]) self.layoutGroup.layout().addWidget(self.layoutCombo) self.startupDialogCheck.clicked.connect( lambda check: self.layoutCombo.setEnabled(not check)) # Application style self.themeGroup = QGroupBox(self) self.themeGroup.setTitle('Application theme') self.themeGroup.setLayout(QVBoxLayout()) self.layout().addWidget(self.themeGroup) self.themeCombo = QComboBox(self.themeGroup) self.themeCombo.addItems(styles.get_styles()) self.themeGroup.layout().addWidget(self.themeCombo)
def _create_buttons(self, layout, title, group): """ Add a button for each module in a group to a layout. """ imports = grid = None row = column = 0 for module_name in sorted(self._metadata.keys()): if self._metadata[module_name].group != group: continue if imports is None: imports = QGroupBox(title) grid = QGridLayout() b = ModuleButton(module_name) b.explicitly_required_changed.connect(self._module_toggled) self._buttons[module_name] = b grid.addWidget(b, row, column) column += 1 if column == 5: row += 1 column = 0 if imports is not None: imports.setLayout(grid) layout.addWidget(imports)
def randomWidget(self): group = QGroupBox("Randomize") layout = QGridLayout() self.randomCount = QSpinBox() layout.addWidget(QLabel(self.tr("Count")), 0, 0) layout.addWidget(self.randomCount, 0, 1) self.minBrushSize = BrushSizeWidget(15) self.maxBrushSize = BrushSizeWidget(50) layout.addWidget(QLabel(self.tr("Min")), 1, 0) layout.addWidget(self.minBrushSize, 1, 1) layout.addWidget(QLabel(self.tr("Max")), 2, 0) layout.addWidget(self.maxBrushSize, 2, 1) self.xAngle = QSpinBox() self.yAngle = QSpinBox() self.zAngle = QSpinBox() layout.addWidget(QLabel(self.tr("Angle X")), 3, 0) layout.addWidget(self.xAngle, 3, 1) layout.addWidget(QLabel(self.tr("Angle Y")), 4, 0) layout.addWidget(self.yAngle, 4, 1) layout.addWidget(QLabel(self.tr("Angle Z")), 5, 0) layout.addWidget(self.zAngle, 5, 1) container = QVBoxLayout() container.addLayout(layout) container.addStretch(1) group.setLayout(container) group.setFixedWidth(150) return group
def intervalButtons(self): widget = QGroupBox('Interval') group = QButtonGroup(widget) layout = QHBoxLayout() widget.setLayout(layout) def setInterval(): self.interval = group.checkedId() interval = self.INTERVALS[self.interval][0] self.updateTitle() if interval: self.progress.show() self.progress.setMaximum(interval) value = self.timer.seconds() if value < interval: self.progress.resume() else: self.progress.stop() self.progress.setValue(min(interval, value)) else: self.progress.hide() for i, interval in enumerate(self.INTERVALS): button = QPushButton(interval[1]) button.setCheckable(True) button.clicked.connect(setInterval) group.addButton(button, i) layout.addWidget(button, 1 if i > 0 else 0) return widget
def __init__(self, parent=None): QGroupBox.__init__(self) self.toggled.connect(self.setExpanded) self.tempWidget = QWidget() self.customStyle = False
def __init__(self, parent=None): super(ConfigurationPage, self).__init__(parent) configGroup = QGroupBox("Server configuration") serverLabel = QLabel("Server:") serverCombo = QComboBox() serverCombo.addItem("Trolltech (Australia)") serverCombo.addItem("Trolltech (Germany)") serverCombo.addItem("Trolltech (Norway)") serverCombo.addItem("Trolltech (People's Republic of China)") serverCombo.addItem("Trolltech (USA)") serverLayout = QHBoxLayout() serverLayout.addWidget(serverLabel) serverLayout.addWidget(serverCombo) configLayout = QVBoxLayout() configLayout.addLayout(serverLayout) configGroup.setLayout(configLayout) mainLayout = QVBoxLayout() mainLayout.addWidget(configGroup) mainLayout.addStretch(1) self.setLayout(mainLayout)
def __init__(self, size, Id, parent=None): super().__init__(size, parent) self.id = Id self.box = QWidget(self) self.box.setGeometry(0, 0, self.width(), 240) self.verticalLayout = QVBoxLayout(self.box) self.verticalLayout.setContentsMargins(0, 0, 0, 0) # FadeIn self.groupFadeIn = QGroupBox(self.box) self.fadeInLayout = QGridLayout(self.groupFadeIn) self.fadeInSpin = QDoubleSpinBox(self.groupFadeIn) self.fadeInSpin.setMaximum(3600) self.fadeInLayout.addWidget(self.fadeInSpin, 0, 0) self.fadeInLabel = QLabel(self.groupFadeIn) self.fadeInLabel.setAlignment(QtCore.Qt.AlignCenter) self.fadeInLayout.addWidget(self.fadeInLabel, 0, 1) self.fadeInCombo = QComboBox(self.groupFadeIn) self.fadeInCombo.setItemDelegate(QStyledItemDelegate()) for key in sorted(self.FadeIn.keys()): self.fadeInCombo.addItem(self.FadeIn[key], key) self.fadeInLayout.addWidget(self.fadeInCombo, 1, 0) self.fadeInExpLabel = QLabel(self.groupFadeIn) self.fadeInExpLabel.setAlignment(QtCore.Qt.AlignCenter) self.fadeInLayout.addWidget(self.fadeInExpLabel, 1, 1) self.verticalLayout.addWidget(self.groupFadeIn) # FadeOut self.groupFadeOut = QGroupBox(self.box) self.fadeOutLayout = QGridLayout(self.groupFadeOut) self.fadeOutSpin = QDoubleSpinBox(self.groupFadeOut) self.fadeOutSpin.setMaximum(3600) self.fadeOutLayout.addWidget(self.fadeOutSpin, 0, 0) self.fadeOutLabel = QLabel(self.groupFadeOut) self.fadeOutLabel.setAlignment(QtCore.Qt.AlignCenter) self.fadeOutLayout.addWidget(self.fadeOutLabel, 0, 1) self.fadeOutCombo = QComboBox(self.groupFadeOut) self.fadeOutCombo.setItemDelegate(QStyledItemDelegate()) for key in sorted(self.FadeOut.keys()): self.fadeOutCombo.addItem(self.FadeOut[key], key) self.fadeOutLayout.addWidget(self.fadeOutCombo, 1, 0) self.fadeOutExpLabel = QLabel(self.groupFadeOut) self.fadeOutExpLabel.setAlignment(QtCore.Qt.AlignCenter) self.fadeOutLayout.addWidget(self.fadeOutExpLabel, 1, 1) self.verticalLayout.addWidget(self.groupFadeOut) self.retranslateUi()
def _createEncodingBox(self): groupbox = QGroupBox(_("File Encoding")) layout = QGridLayout() self._autoEncoding = QCheckBox(_("Auto input encoding"), self) self._inputEncoding = QComboBox(self) self._inputEncoding.addItems(ALL_ENCODINGS) self._inputEncoding.setDisabled(self._autoEncoding.isChecked()) inputLabel = QLabel(_("Input encoding")) self._changeEncoding = QCheckBox(_("Change encoding on save"), self) self._outputEncoding = QComboBox(self) self._outputEncoding.addItems(ALL_ENCODINGS) self._outputEncoding.setEnabled(self._changeEncoding.isChecked()) outputLabel = QLabel(_("Output encoding")) layout.addWidget(self._autoEncoding, 0, 0) layout.addWidget(self._inputEncoding, 1, 0) layout.addWidget(inputLabel, 1, 1) layout.addWidget(self._changeEncoding, 2, 0) layout.addWidget(self._outputEncoding, 3, 0) layout.addWidget(outputLabel, 3, 1) groupbox.setLayout(layout) return groupbox
def update(self): for _ in range(self.layout().count()): self.layout().itemAt(0).widget().close() self.layout().takeAt(0) qsa = QScrollArea() scroll_area_widget = QWidget() layout = QVBoxLayout() scroll_area_widget.setLayout(layout) model = self.result.model cycles_per_ms = model.cycles_per_ms for proc in model.processors: proc_r = self.result.processors[proc] gb = QGroupBox(proc.name) gb_layout = QVBoxLayout() gb.setLayout(gb_layout) gb_layout.addWidget(QLabel( "Cxt Save count: {}".format(proc_r.context_save_count))) gb_layout.addWidget(QLabel( "Cxt Load count: {}".format(proc_r.context_load_count))) gb_layout.addWidget(QLabel( "Cxt Save overhead: {0:.4f}ms ({1:.0f} cycles)".format( float(proc_r.context_save_overhead) / cycles_per_ms, proc_r.context_save_overhead))) gb_layout.addWidget(QLabel( "Cxt Load overhead: {0:.4f}ms ({1:.0f} cycles)".format( float(proc_r.context_load_overhead) / cycles_per_ms, proc_r.context_load_overhead))) layout.addWidget(gb) qsa.setWidget(scroll_area_widget) self.layout().addWidget(qsa)
def __init__(self, parent=None): super().__init__(parent) self._items = list() self._item_dictionary = collections.OrderedDict() self.ui_buttons = LinkButtons(self) self.ui_link_list = KeyList(self) layout_h = QHBoxLayout() layout_h.addWidget(self.ui_link_list) layout_h.addWidget(self.ui_buttons) group_box = QGroupBox("Linked terms and files") group_box.setLayout(layout_h) layout_h_b = QHBoxLayout() layout_h_b.addWidget(group_box) self.setLayout(layout_h_b) self.ui_buttons.form.buttonLinkTerms.clicked.connect( self.linkTermsClicked) self.ui_buttons.form.buttonUnlinkTerms.clicked.connect( self.unlinkTermsClicked) self.ui_buttons.form.buttonAddFile.clicked.connect( self.add_file) self.ui_buttons.form.buttonRemoveFiles.clicked.connect( self.remove_files)
def __init__(self, msg, choices, on_clicked=None, checked_index=0): vbox = QVBoxLayout() if len(msg) > 50: vbox.addWidget(WWLabel(msg)) msg = "" gb2 = QGroupBox(msg) vbox.addWidget(gb2) vbox2 = QVBoxLayout() gb2.setLayout(vbox2) self.group = group = QButtonGroup() for i,c in enumerate(choices): button = QRadioButton(gb2) button.setText(c) vbox2.addWidget(button) group.addButton(button) group.setId(button, i) if i==checked_index: button.setChecked(True) if on_clicked: group.buttonClicked.connect(partial(on_clicked, self)) self.vbox = vbox
def _close_group(self, main_layout, group_name, group_layout): """Closes the the existing group, used during controls creation """ debug_print('FormContainer._close_group close group', group_name) # The widget that holds this group's controls controls_widget = QWidget() controls_widget.setLayout(group_layout) if group_name: # Group controls start out hidden controls_widget.setVisible(False) # The group box, which contains the label to toggle the controls # and the controls themselves group_box_layout = QVBoxLayout() group_box_layout.addWidget(ToggleWidgetLabel( group_name, controls_widget, initially_visible=False )) group_box_layout.addWidget(controls_widget) group_box_layout.setContentsMargins( 0, # left 0, # top 0, # right 0 # bottom ) group_box = QGroupBox() group_box.setLayout(group_box_layout) # Add the group box to the main layout main_layout.addRow(group_box) else: # current group has no name and therefore no toggle group main_layout.addRow(controls_widget)
def __init__(self, size, cue=None, parent=None): super().__init__(size, cue=cue, parent=parent) self.setLayout(QVBoxLayout(self)) # Groups self.groupGroups = QGroupBox(self) self.groupGroups.setTitle("Edit groups") self.ggHLayout = QHBoxLayout(self.groupGroups) self.editGroups = QLineEdit(self.groupGroups) regex = QtCore.QRegExp('(\d+,)*') self.editGroups.setValidator(QRegExpValidator(regex)) sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.editGroups.setSizePolicy(sizePolicy) self.ggHLayout.addWidget(self.editGroups) self.groupsEditLabel = QLabel(self.groupGroups) self.groupsEditLabel.setText("Modify groups [0,1,2,...,n]") self.groupsEditLabel.setAlignment(QtCore.Qt.AlignCenter) self.ggHLayout.addWidget(self.groupsEditLabel) self.layout().addWidget(self.groupGroups) # Action self.groupAction = QGroupBox(self) self.groupAction.setTitle("Select action") self.gaHLayout = QHBoxLayout(self.groupAction) self.actionsBox = QComboBox(self.groupAction) self.actionsBox.addItems(self.ACTIONS) self.gaHLayout.addWidget(self.actionsBox) self.layout().addWidget(self.groupAction) self.layout().addSpacing(self.height() - 200)
def __init__(self, size, parent=None): super().__init__(size, parent) # Startup layout self.layoutGroup = QGroupBox(self) self.layoutGroup.setTitle('Startup layout') self.layoutGroup.setLayout(QVBoxLayout()) self.layoutGroup.setGeometry(0, 0, self.width(), 120) self.startupDialogCheck = QCheckBox(self.layoutGroup) self.startupDialogCheck.setText('Use startup dialog') self.layoutGroup.layout().addWidget(self.startupDialogCheck) self.layoutCombo = QComboBox(self.layoutGroup) self.layoutCombo.addItems([lay.NAME for lay in layouts.get_layouts()]) self.layoutGroup.layout().addWidget(self.layoutCombo) self.startupDialogCheck.clicked.connect( lambda check: self.layoutCombo.setEnabled(not check)) # Application style self.themeGroup = QGroupBox(self) self.themeGroup.setTitle('Application theme') self.themeGroup.setLayout(QVBoxLayout()) self.themeGroup.setGeometry(0, 125, self.width(), 80) self.themeCombo = QComboBox(self.themeGroup) self.themeCombo.addItems(styles.get_styles()) self.themeGroup.layout().addWidget(self.themeCombo)
def __init__(self, parent=None): super().__init__(parent) self.setSubTitle(self.tr("<h2>Save Your Settings</h2>")) vlayout = QVBoxLayout(self) label = QLabel(self) label.setWordWrap(True) label.setText(self.tr("<p>You have successfully finished all steps. Here's a summary of the settings you want to apply. \ Click <strong>Apply Settings</strong> to save them now. You are now ready to enjoy KaOS!</p>")) vlayout.addWidget(label) vlayout.addItem(QSpacerItem(20, 40, QSizePolicy.Preferred, QSizePolicy.Preferred)) groupBox = QGroupBox() groupBox.setTitle(self.tr("The following settings will be applied")) groupBox.setMinimumHeight(350) groupLayout = QHBoxLayout(groupBox) self.labelSummary = QLabel() self.labelSummary.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop) groupLayout.addWidget( self.labelSummary) self.labelSummary2 = QLabel() self.labelSummary2.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop) groupLayout.addWidget( self.labelSummary2) vlayout.addWidget(groupBox) vlayout.addItem(QSpacerItem(20, 40, QSizePolicy.Preferred, QSizePolicy.Preferred)) self.summary = {} self.parent().summaryVisible.connect(self.summaryWrite)
def __init__(self, parent): QWidget.__init__(self, parent) self.parent = parent self.objets = parent.objets self.panel = self.parent.parent.panel self.canvas = self.parent.parent.canvas self.islabel = self.parent.parent.islabel self.sizer = QVBoxLayout() if len(self.objets) is 1: self.objet = self.objets[0] style = QVBoxLayout() style_box = QGroupBox("Style de l'objet") style_box.setLayout(style) style.addWidget(QLabel("<span style='color:red;font-style:italic;'>Attention, ne modifiez ce contenu que si vous savez ce que vous faites.</span>")) self.avance = QTextEdit() self.avance.setMinimumSize(350, 200) self.actualiser() style.addWidget(self.avance) self.sizer.addWidget(style_box) ok = QPushButton('OK') appliquer = QPushButton("Appliquer") actualiser = QPushButton("Actualiser") ok.clicked.connect(self.EvtOk) appliquer.clicked.connect(self.EvtAppliquer) actualiser.clicked.connect(self.actualiser) boutons = QHBoxLayout() boutons.addWidget(ok) boutons.addWidget(appliquer) boutons.addWidget(actualiser) self.sizer.addLayout(boutons) self.setLayout(self.sizer)
def _informationWidget(self): group = QGroupBox() group.setTitle(catalog.i18nc("@title:groupbox", "System information")) layout = QVBoxLayout() label = QLabel() try: from UM.Application import Application self.cura_version = Application.getInstance().getVersion() except: self.cura_version = catalog.i18nc("@label unknown version of Cura", "Unknown") crash_info = "<b>" + catalog.i18nc("@label Cura version number", "Cura version") + ":</b> " + str(self.cura_version) + "<br/>" crash_info += "<b>" + catalog.i18nc("@label Type of platform", "Platform") + ":</b> " + str(platform.platform()) + "<br/>" crash_info += "<b>" + catalog.i18nc("@label", "Qt version") + ":</b> " + str(QT_VERSION_STR) + "<br/>" crash_info += "<b>" + catalog.i18nc("@label", "PyQt version") + ":</b> " + str(PYQT_VERSION_STR) + "<br/>" crash_info += "<b>" + catalog.i18nc("@label OpenGL version", "OpenGL") + ":</b> " + str(self._getOpenGLInfo()) + "<br/>" label.setText(crash_info) layout.addWidget(label) group.setLayout(layout) self.data["cura_version"] = self.cura_version self.data["os"] = {"type": platform.system(), "version": platform.version()} self.data["qt_version"] = QT_VERSION_STR self.data["pyqt_version"] = PYQT_VERSION_STR return group
def __init__(self, parent=None): """Initiate the abstract widget that is displayed in the preferences dialog.""" super(Playback, self).__init__(parent) self.user_config_file = os.path.join(AppDirs('mosaic', 'Mandeep').user_config_dir, 'settings.toml') with open(self.user_config_file) as conffile: config = toml.load(conffile) playback_config = QGroupBox('Playback Configuration') playback_config_layout = QVBoxLayout() playback_config_layout.setAlignment(Qt.AlignTop) self.cover_art_playback = QCheckBox('Cover Art Playback') self.playlist_save_checkbox = QCheckBox('Save Playlist on Close') playback_config_layout.addWidget(self.cover_art_playback) playback_config_layout.addWidget(self.playlist_save_checkbox) playback_config.setLayout(playback_config_layout) main_layout = QVBoxLayout() main_layout.addWidget(playback_config) self.setLayout(main_layout) self.check_playback_setting(config) self.check_playlist_save(config) self.cover_art_playback.clicked.connect(lambda: self.cover_art_playback_setting(config)) self.playlist_save_checkbox.clicked.connect(lambda: self.playlist_save_setting(config))
def makeCallButtonCtrl(self): self.calButtonControl = CalibrateDialog(self) self.clear_cal = QPushButton('Clear Calibration') self.load_factory_cal = QPushButton('Load Factory Calibration') self.load_local_cal = QPushButton('Load Local Calibration') self.do_cal = QPushButton('Start Calibration Procedure') self.clear_cal.clicked.connect(self.buttonManageCal_clear_evt) self.load_factory_cal.clicked.connect(self.buttonManageCal_loadFactory_evt) self.load_local_cal.clicked.connect(self.buttonManageCal_loadLocal_evt) self.do_cal.clicked.connect(self.buttonCalibrate_evt) layout = QVBoxLayout() layout.addWidget(self.clear_cal) layout.addWidget(self.load_factory_cal) layout.addWidget(self.load_local_cal) layout.addWidget(self.do_cal) ip_container = QGroupBox("Calibrate"); ip_container.setLayout(layout) return ip_container
def makeIpContainer(self): self.targetIpWidget = QLineEdit('192.168.1.193') self.targetPortWidget = QLineEdit('%s' % str(1025+self.vna_no)) self.connectButton = QPushButton('Connect') self.runButton = QPushButton('Run') self.runButton.setCheckable(True) self.runButton.setEnabled(False) self.connectButton.clicked.connect(self.buttonConnect_evt) self.runButton.clicked.connect(self.buttonRun_evt) inputlayout = QGridLayout() inputlayout.addWidget(QLabel('IP:'), 0, 0, 1, 1) inputlayout.addWidget(QLabel('Port:'), 1, 0, 1, 1) inputlayout.addWidget(self.targetIpWidget, 0, 1, 1, 3) inputlayout.addWidget(self.targetPortWidget, 1, 1, 1, 3) buttonlayout = QGridLayout() buttonlayout.addWidget(self.connectButton, 1, 0) buttonlayout.addWidget(self.runButton, 1, 1) layout = QVBoxLayout() layout.addLayout(inputlayout) layout.addLayout(buttonlayout) ip_container = QGroupBox("IP Address"); ip_container.setLayout(layout) return ip_container
def __init__(self, parent, settings_object): super().__init__() self.parent = parent self.settings_object = settings_object media_group = QGroupBox('Media Files') media_group_layout = QHBoxLayout() media_path_label = QLabel('Media Folder:') self.media_path_edit = QLineEdit(self.settings_object['output']['media_directory']) media_path_browse_button = QPushButton('Browse') media_path_browse_button.clicked.connect(self.browse_media_directory) self.media_path_edit.textEdited.connect(self.set_media_directory) media_group_layout.addWidget(media_path_label) media_group_layout.addWidget(self.media_path_edit) media_group_layout.addWidget(media_path_browse_button) media_group.setLayout(media_group_layout) schema_group = QGroupBox('Output File Naming Schema') main_layout = QVBoxLayout() main_layout.addWidget(media_group) main_layout.addWidget(schema_group) main_layout.addStretch(1) self.setLayout(main_layout)
def _getVClampCtrlBox(self): vClampPanel = QGroupBox(self) self._vClampCtrlBox = vClampPanel self._holdingVLabel = QLabel("Holding Voltage (mV)", vClampPanel) self._holdingVEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.holdingV']), vClampPanel) self._holdingTimeLabel = QLabel("Holding Time (ms)", vClampPanel) self._holdingTimeEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.holdingT']), vClampPanel) self._prePulseVLabel = QLabel("Pre-pulse Voltage (mV)", vClampPanel) self._prePulseVEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.prepulseV']), vClampPanel) self._prePulseTimeLabel = QLabel("Pre-pulse Time (ms)", vClampPanel) self._prePulseTimeEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.prepulseT']), vClampPanel) self._clampVLabel = QLabel("Clamp Voltage (mV)", vClampPanel) self._clampVEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.clampV']), vClampPanel) self._clampTimeLabel = QLabel("Clamp Time (ms)", vClampPanel) self._clampTimeEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.clampT']), vClampPanel) for child in vClampPanel.children(): if isinstance(child, QLineEdit): set_default_line_edit_size(child) layout = QGridLayout(vClampPanel) layout.addWidget(self._holdingVLabel, 0, 0) layout.addWidget(self._holdingVEdit, 0, 1) layout.addWidget(self._holdingTimeLabel, 1, 0) layout.addWidget(self._holdingTimeEdit, 1, 1) layout.addWidget(self._prePulseVLabel, 2, 0) layout.addWidget(self._prePulseVEdit, 2, 1) layout.addWidget(self._prePulseTimeLabel,3,0) layout.addWidget(self._prePulseTimeEdit, 3, 1) layout.addWidget(self._clampVLabel, 4, 0) layout.addWidget(self._clampVEdit, 4, 1) layout.addWidget(self._clampTimeLabel, 5, 0) layout.addWidget(self._clampTimeEdit, 5, 1) layout.setRowStretch(6, 1.0) vClampPanel.setLayout(layout) return self._vClampCtrlBox
def createHorizontalGroupBox(self): self.horizontalGroupBox = QGroupBox() layout = QHBoxLayout() self.sectionTreeWidget.setHeaderHidden(1) layout.addWidget(self.sectionTreeWidget, 0) self.sectionTreeWidget.setStyleSheet("background-color: rgb(215,227,229)") self.notesListWidget.setWindowTitle('Notes') layout.addWidget(self.notesListWidget, 0) self.notesListWidget.setStyleSheet("QListWidget {background-color: rgb(196,226,233)}") subVBox = QGroupBox() vLayout = QVBoxLayout() self.titleLabel = QLabel() vLayout.addWidget(self.titleLabel, 0) self.view = QWebView() vLayout.addWidget(self.view, 1) subVBox.setLayout(vLayout) layout.addWidget(subVBox, 1) self.horizontalGroupBox.setLayout(layout)
def __init__(self, element_id, **kwargs): super().__init__(element_id) self.setLayout(QVBoxLayout()) self.layout().setAlignment(Qt.AlignTop) self.serverGroup = QGroupBox(self) self.serverGroup.setTitle('Jack') self.serverGroup.setLayout(QHBoxLayout()) self.layout().addWidget(self.serverGroup) self.serverLineEdit = QLineEdit(self.serverGroup) self.serverLineEdit.setToolTip('Name of the server to connect with') self.serverLineEdit.setText('default') self.serverGroup.layout().addWidget(self.serverLineEdit) self.serverLineEditLabel = QLabel('Sever name', self.serverGroup) self.serverLineEditLabel.setAlignment(QtCore.Qt.AlignCenter) self.serverGroup.layout().addWidget(self.serverLineEditLabel) self.connectionsGroup = QGroupBox(self) self.connectionsGroup.setTitle('Connections') self.connectionsGroup.setLayout(QHBoxLayout()) self.layout().addWidget(self.connectionsGroup) self.connectionsEdit = QPushButton('Edit connections', self) self.connectionsEdit.clicked.connect(self.__edit_connections) self.connectionsGroup.layout().addWidget(self.connectionsEdit) self.__jack_client = jack.Client('LinuxShowPlayer_SettingsControl') self.connections = JackSink.default_connections(self.__jack_client)
def initAppletDrawerUi(self): training_controls = EdgeTrainingGui.createDrawerControls(self) training_controls.layout().setContentsMargins(5,0,5,0) training_layout = QVBoxLayout() training_layout.addWidget( training_controls ) training_layout.setContentsMargins(0,15,0,0) training_box = QGroupBox( "Training", parent=self ) training_box.setLayout(training_layout) training_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) multicut_controls = MulticutGuiMixin.createDrawerControls(self) multicut_controls.layout().setContentsMargins(5,0,5,0) multicut_layout = QVBoxLayout() multicut_layout.addWidget( multicut_controls ) multicut_layout.setContentsMargins(0,15,0,0) multicut_box = QGroupBox( "Multicut", parent=self ) multicut_box.setLayout(multicut_layout) multicut_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) drawer_layout = QVBoxLayout() drawer_layout.addWidget(training_box) drawer_layout.addWidget(multicut_box) drawer_layout.setSpacing(2) drawer_layout.setContentsMargins(5,5,5,5) drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) self._drawer = QWidget(parent=self) self._drawer.setLayout(drawer_layout)
def draw_inputs_segment(self): input_segment = QGroupBox("Enter address to count keywords") layout = QHBoxLayout() layout.addWidget(self.input, 0) layout.addWidget(self.button) input_segment.setLayout(layout) return input_segment
def __init__(self, name, timeValue): super(QDialog, self).__init__() self.resize(300, 150) timeContainer = QGroupBox() timeContainer.setTitle('Time (ms)') self.lineEdit = QLineEdit() fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.lineEdit.setFont(fixedWidthFont) self.lineEdit.setText(str(timeValue)) vLayout = QVBoxLayout() vLayout.addWidget(self.lineEdit) self.cancelButton = QPushButton() self.cancelButton.setText('Cancel') self.cancelButton.clicked.connect(self.cancelClicked) self.acceptButton = QPushButton() self.acceptButton.setText('Accept') self.acceptButton.clicked.connect(self.acceptClicked) buttonContainer = QWidget() hLayout = QHBoxLayout() hLayout.addWidget(self.cancelButton) hLayout.addWidget(self.acceptButton) buttonContainer.setLayout(hLayout) vLayout.addWidget(buttonContainer) timeContainer.setLayout(vLayout) vLayout2 = QVBoxLayout() vLayout2.addWidget(timeContainer) self.setLayout(vLayout2)
def setupUi(self, Form): Form.setObjectName(_fromUtf8("QRangeSlider")) Form.resize(300, 30) Form.setStyleSheet(_fromUtf8(DEFAULT_CSS)) self.gridLayout = QtGui.QGridLayout(Form) self.gridLayout.setMargin(0) self.gridLayout.setSpacing(0) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self._splitter = QtGui.QSplitter(Form) self._splitter.setMinimumSize(QtCore.QSize(0, 0)) self._splitter.setMaximumSize(QtCore.QSize(16777215, 16777215)) self._splitter.setOrientation(QtCore.Qt.Horizontal) self._splitter.setObjectName(_fromUtf8("splitter")) self._head = QGroupBox(self._splitter) self._head.setTitle(_fromUtf8("")) self._head.setObjectName(_fromUtf8("Head")) self._handle = QGroupBox(self._splitter) self._handle.setTitle(_fromUtf8("")) self._handle.setObjectName(_fromUtf8("Span")) self._tail = QGroupBox(self._splitter) self._tail.setTitle(_fromUtf8("")) self._tail.setObjectName(_fromUtf8("Tail")) self.gridLayout.addWidget(self._splitter, 0, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
class PreviewWidgetColor(QGroupBox): def __init__(self, parent=None): super().__init__(parent) self.setTitle(self.tr("Preview")) self.setMaximumHeight(120) self.parent = parent vboxLayout = QVBoxLayout(self) self.previewGroupBox = QGroupBox(self) self.previewGroupBox.setObjectName("previewGroupBox") vboxLayout.addWidget(self.previewGroupBox) self.horizontalLayout = QHBoxLayout(self.previewGroupBox) self.verticalLayout = QVBoxLayout() self.horizontalLayout.addLayout(self.verticalLayout) self.previewLabel = QLabel(self.previewGroupBox) self.previewLabel.setText(self.tr("Window Text")) self.previewLabel.setObjectName("previewLabel") self.verticalLayout.addWidget(self.previewLabel) self.previewPushButton = QPushButton(self.previewGroupBox) self.previewPushButton.setText(self.tr("Button")) self.previewPushButton.setObjectName("previewPushButton") self.verticalLayout.addWidget(self.previewPushButton) self.previewTextBrowser = QTextBrowser(self.previewGroupBox) self.previewTextBrowser.setObjectName("previewTextBrowser") css = iniToCss(os.path.join("/usr/share/color-schemes", self.parent.children()[1].currentItem().colorSchemeName)) self.previewTextBrowser.setHtml("""<style>#unclicked {color : rgb(%s);} #clicked {color : rgb(%s);}</style>"""%(css[1][0],css[1][1]) + self.tr("""<p>Normal text <a id='unclicked' href='#'>link</a> <a id='clicked' href='#'>visited</a></p>""")) self.horizontalLayout.addWidget(self.previewTextBrowser) self.previewPushButton.installEventFilter(self.previewGroupBox) self.previewPushButton.setFocusPolicy(Qt.NoFocus) self.previewTextBrowser.installEventFilter(self.previewGroupBox) self.previewTextBrowser.setFocusPolicy(Qt.NoFocus) self.previewTextBrowser.setTextInteractionFlags(Qt.NoTextInteraction) def eventFilter(self, obj, event): if self.previewPushButton: if event.type() == QEvent.MouseButtonRelease: return True elif event.type() == QEvent.MouseButtonPress: return True elif event.type() == QEvent.MouseButtonDblClick: return True else: return False else: super().eventFilter(obj, event)
def request_safe_t_init_settings(self, wizard, method, device): vbox = QVBoxLayout() next_enabled = True label = QLabel(_("Enter a label to name your device:")) name = QLineEdit() hl = QHBoxLayout() hl.addWidget(label) hl.addWidget(name) hl.addStretch(1) vbox.addLayout(hl) def clean_text(widget): text = widget.toPlainText().strip() return ' '.join(text.split()) if method in [TIM_NEW, TIM_RECOVER]: gb = QGroupBox() hbox1 = QHBoxLayout() gb.setLayout(hbox1) vbox.addWidget(gb) gb.setTitle(_("Select your seed length:")) bg = QButtonGroup() for i, count in enumerate([12, 18, 24]): rb = QRadioButton(gb) rb.setText(_("{:d} words").format(count)) bg.addButton(rb) bg.setId(rb, i) hbox1.addWidget(rb) rb.setChecked(True) cb_pin = QCheckBox(_('Enable PIN protection')) cb_pin.setChecked(True) else: text = QTextEdit() text.setMaximumHeight(60) if method == TIM_MNEMONIC: msg = _("Enter your BIP39 mnemonic:") else: msg = _("Enter the master private key beginning with xprv:") def set_enabled(): from electrum_nmc.bip32 import is_xprv wizard.next_button.setEnabled(is_xprv(clean_text(text))) text.textChanged.connect(set_enabled) next_enabled = False vbox.addWidget(QLabel(msg)) vbox.addWidget(text) pin = QLineEdit() pin.setValidator(QRegExpValidator(QRegExp('[1-9]{0,9}'))) pin.setMaximumWidth(100) hbox_pin = QHBoxLayout() hbox_pin.addWidget(QLabel(_("Enter your PIN (digits 1-9):"))) hbox_pin.addWidget(pin) hbox_pin.addStretch(1) if method in [TIM_NEW, TIM_RECOVER]: vbox.addWidget(WWLabel(RECOMMEND_PIN)) vbox.addWidget(cb_pin) else: vbox.addLayout(hbox_pin) passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT) passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN) passphrase_warning.setStyleSheet("color: red") cb_phrase = QCheckBox(_('Enable passphrases')) cb_phrase.setChecked(False) vbox.addWidget(passphrase_msg) vbox.addWidget(passphrase_warning) vbox.addWidget(cb_phrase) wizard.exec_layout(vbox, next_enabled=next_enabled) if method in [TIM_NEW, TIM_RECOVER]: item = bg.checkedId() pin = cb_pin.isChecked() else: item = ' '.join(str(clean_text(text)).split()) pin = str(pin.text()) return (item, name.text(), pin, cb_phrase.isChecked())
def __init__(self, parent): super(GeneralConfiguration, self).__init__() self._preferences = parent vbox = QVBoxLayout(self) groupBoxStart = QGroupBox(translations.TR_PREFERENCES_GENERAL_START) groupBoxClose = QGroupBox(translations.TR_PREFERENCES_GENERAL_CLOSE) groupBoxWorkspace = QGroupBox( translations.TR_PREFERENCES_GENERAL_WORKSPACE) groupBoxNoti = QGroupBox(translations.TR_NOTIFICATION) groupBoxReset = QGroupBox(translations.TR_PREFERENCES_GENERAL_RESET) #Start vboxStart = QVBoxLayout(groupBoxStart) self._checkLastSession = QCheckBox( translations.TR_PREFERENCES_GENERAL_LOAD_LAST_SESSION) self._checkActivatePlugins = QCheckBox( translations.TR_PREFERENCES_GENERAL_ACTIVATE_PLUGINS) self._checkNotifyUpdates = QCheckBox( translations.TR_PREFERENCES_GENERAL_NOTIFY_UPDATES) self._checkShowStartPage = QCheckBox( translations.TR_PREFERENCES_GENERAL_SHOW_START_PAGE) vboxStart.addWidget(self._checkLastSession) vboxStart.addWidget(self._checkActivatePlugins) vboxStart.addWidget(self._checkNotifyUpdates) vboxStart.addWidget(self._checkShowStartPage) #Close vboxClose = QVBoxLayout(groupBoxClose) self._checkConfirmExit = QCheckBox( translations.TR_PREFERENCES_GENERAL_CONFIRM_EXIT) vboxClose.addWidget(self._checkConfirmExit) #Workspace and Project gridWorkspace = QGridLayout(groupBoxWorkspace) self._txtWorkspace = QLineEdit() ui_tools.LineEditButton( self._txtWorkspace, self._txtWorkspace.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self._txtWorkspace.setReadOnly(True) self._btnWorkspace = QPushButton(QIcon(':img/openFolder'), '') gridWorkspace.addWidget( QLabel(translations.TR_PREFERENCES_GENERAL_WORKSPACE), 0, 0, Qt.AlignRight) gridWorkspace.addWidget(self._txtWorkspace, 0, 1) gridWorkspace.addWidget(self._btnWorkspace, 0, 2) self._txtExtensions = QLineEdit() self._txtExtensions.setToolTip( translations.TR_PROJECT_EXTENSIONS_TOOLTIP) gridWorkspace.addWidget(QLabel( translations.TR_PREFERENCES_GENERAL_SUPPORTED_EXT), 1, 0, Qt.AlignRight) gridWorkspace.addWidget(self._txtExtensions, 1, 1) labelTooltip = QLabel(translations.TR_PROJECT_EXTENSIONS_INSTRUCTIONS) gridWorkspace.addWidget(labelTooltip, 2, 1) # Notification hboxNoti, self._notify_position = QHBoxLayout(groupBoxNoti), QComboBox() self._notify_position.addItems( [translations.TR_BOTTOM + "-" + translations.TR_LEFT, translations.TR_BOTTOM + "-" + translations.TR_RIGHT, translations.TR_TOP + "-" + translations.TR_LEFT, translations.TR_TOP + "-" + translations.TR_RIGHT]) self._notify_color = QPushButton( translations.TR_EDITOR_SCHEME_PICK_COLOR) self._notification_choosed_color = settings.NOTIFICATION_COLOR hboxNoti.addWidget(QLabel(translations.TR_POSITION_ON_SCREEN)) hboxNoti.addWidget(self._notify_position) hboxNoti.addWidget(self._notify_color, 0, Qt.AlignRight) # Resetting preferences vboxReset = QVBoxLayout(groupBoxReset) self._btnReset = QPushButton( translations.TR_PREFERENCES_GENERAL_RESET_PREFERENCES) vboxReset.addWidget(self._btnReset, alignment=Qt.AlignLeft) #Settings qsettings = IDE.ninja_settings() qsettings.beginGroup('preferences') qsettings.beginGroup('general') self._checkLastSession.setChecked( qsettings.value('loadFiles', True, type=bool)) self._checkActivatePlugins.setChecked( qsettings.value('activatePlugins', defaultValue=True, type=bool)) self._checkNotifyUpdates.setChecked( qsettings.value('preferences/general/notifyUpdates', defaultValue=True, type=bool)) self._checkShowStartPage.setChecked(settings.SHOW_START_PAGE) self._checkConfirmExit.setChecked(settings.CONFIRM_EXIT) self._txtWorkspace.setText(settings.WORKSPACE) extensions = ', '.join(settings.SUPPORTED_EXTENSIONS) self._txtExtensions.setText(extensions) self._notify_position.setCurrentIndex(settings.NOTIFICATION_POSITION) qsettings.endGroup() qsettings.endGroup() vbox.addWidget(groupBoxStart) vbox.addWidget(groupBoxClose) vbox.addWidget(groupBoxWorkspace) vbox.addWidget(groupBoxNoti) vbox.addWidget(groupBoxReset) #Signals self._btnWorkspace.clicked['bool'].connect(self._load_workspace) self._notify_color.clicked['bool'].connect(self._pick_color) self._btnReset.clicked['bool'].connect(self._reset_preferences) self._preferences.savePreferences.connect(self.save)
def __init__(self, parent, box_type='select'): super().__init__() self.parent = parent self.box_type = box_type self.material = MaterialProperties() self.material_name = '' self.boxGroup = QGroupBox('Material Settings', self.parent) self.gridLayout = QGridLayout(self.boxGroup) self.materialBoxGroup = QGroupBox('', self.boxGroup) self.miniLayout = QHBoxLayout(self.materialBoxGroup) self.label_mat_name = QLabel(self.materialBoxGroup) self.label_mat_name.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.material_name_widget = QComboBox() self.miniLayout.addWidget(self.label_mat_name) # self.miniLayout.addWidget(self.material_name_wid) self.materialBoxGroup.setLayout(self.miniLayout) self.label_Density = QLabel('Density (kg/m^3)', self.boxGroup) self.label_Density.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_Density = QLineEdit(self.boxGroup) self.label_spHeat = QLabel('Specific Heat (J/kg.K)', self.boxGroup) self.label_spHeat.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_spHeat = QLineEdit(self.boxGroup) self.label_Conductivity = QLabel('Thermal Conductivity (W/m.K)', self.boxGroup) self.label_Conductivity.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_Conductivity = QLineEdit(self.boxGroup) self.label_meltPt = QLabel('Melting Temperature (K)', self.boxGroup) self.label_meltPt.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_meltPt = QLineEdit(self.boxGroup) self.label_Emissivity = QLabel('Emissivity (0-1)', self.boxGroup) self.label_Emissivity.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_Emissivity = QLineEdit(self.boxGroup) self.label_Reflect = QLabel('Reflectivity (0-1)', self.boxGroup) self.label_Reflect.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_Reflect = QLineEdit(self.boxGroup) self.label_blank = QLabel(' ', self.boxGroup) self.label_blank.setFixedWidth(60) self.gridLayout.addWidget(self.materialBoxGroup, 0, 0, 1, 3) self.gridLayout.addWidget(self.label_Density, 1, 0) self.gridLayout.addWidget(self.entry_Density, 1, 1) self.gridLayout.addWidget(self.label_blank, 1, 2) self.gridLayout.addWidget(self.label_spHeat, 1, 3) self.gridLayout.addWidget(self.entry_spHeat, 1, 4) self.gridLayout.addWidget(self.label_Conductivity, 2, 0) self.gridLayout.addWidget(self.entry_Conductivity, 2, 1) self.gridLayout.addWidget(self.label_meltPt, 2, 3) self.gridLayout.addWidget(self.entry_meltPt, 2, 4) self.gridLayout.addWidget(self.label_Emissivity, 3, 0) self.gridLayout.addWidget(self.entry_Emissivity, 3, 1) self.gridLayout.addWidget(self.label_Reflect, 3, 3) self.gridLayout.addWidget(self.entry_Reflect, 3, 4) self.boxGroup.setLayout(self.gridLayout) if self.box_type == 'entry': self.new_material_entry() else: self.material_select_box() self.material_name_widget.activated[str].connect( self.on_material_select)
def _exceptionInfoWidget(self): group = QGroupBox() group.setTitle(catalog.i18nc("@title:groupbox", "Error traceback")) layout = QVBoxLayout() text_area = QTextEdit() trace_list = traceback.format_exception(self.exception_type, self.value, self.traceback) trace = "".join(trace_list) text_area.setText(trace) text_area.setReadOnly(True) layout.addWidget(text_area) group.setLayout(layout) # Parsing all the information to fill the dictionary summary = "" if len(trace_list) >= 1: summary = trace_list[len(trace_list)-1].rstrip("\n") module = [""] if len(trace_list) >= 2: module = trace_list[len(trace_list)-2].rstrip("\n").split("\n") module_split = module[0].split(", ") filepath_directory_split = module_split[0].split("\"") filepath = "" if len(filepath_directory_split) > 1: filepath = filepath_directory_split[1] directory, filename = os.path.split(filepath) line = "" if len(module_split) > 1: line = int(module_split[1].lstrip("line ")) function = "" if len(module_split) > 2: function = module_split[2].lstrip("in ") code = "" if len(module) > 1: code = module[1].lstrip(" ") # Using this workaround for a cross-platform path splitting split_path = [] folder_name = "" # Split until reach folder "cura" while folder_name != "cura": directory, folder_name = os.path.split(directory) if not folder_name: break split_path.append(folder_name) # Look for plugins. If it's not a plugin, the current cura version is set isPlugin = False module_version = self.cura_version module_name = "Cura" if split_path.__contains__("plugins"): isPlugin = True # Look backwards until plugin.json is found directory, name = os.path.split(filepath) while not os.listdir(directory).__contains__("plugin.json"): directory, name = os.path.split(directory) json_metadata_file = os.path.join(directory, "plugin.json") try: with open(json_metadata_file, "r", encoding = "utf-8") as f: try: metadata = json.loads(f.read()) module_version = metadata["version"] module_name = metadata["name"] except json.decoder.JSONDecodeError: # Not throw new exceptions Logger.logException("e", "Failed to parse plugin.json for plugin %s", name) except: # Not throw new exceptions pass exception_dict = dict() exception_dict["traceback"] = {"summary": summary, "full_trace": trace} exception_dict["location"] = {"path": filepath, "file": filename, "function": function, "code": code, "line": line, "module_name": module_name, "version": module_version, "is_plugin": isPlugin} self.data["exception"] = exception_dict return group
def initUi(self): #::-------------------------------------------------------------- # We create the type of layout QVBoxLayout (Vertical Layout ) # This type of layout comes from QWidget #::-------------------------------------------------------------- self.setWindowTitle(self.Title) self.main_widget = QWidget(self) self.layout = QVBoxLayout(self.main_widget) # Creates vertical layout self.groupBox2 = QGroupBox('Results') self.groupBox2Layout = QVBoxLayout() self.groupBox2.setLayout(self.groupBox2Layout) self.groupBox3 = QGroupBox('Graphic') self.groupBox3Layout = QVBoxLayout() self.groupBox3.setLayout(self.groupBox3Layout) self.label1 = QLabel("Best Hyperparameter: {'max_depth': 6, 'min_samples_leaf': 1, 'min_samples_split': 2}") self.label2 = QLabel("Accuracy: 34.33") self.groupBox2Layout.addWidget(self.label1) self.groupBox2Layout.addWidget(self.label2) # figure and canvas figure to draw the graph is created to self.fig = Figure() self.ax1 = self.fig.add_subplot(111) self.canvas = FigureCanvas(self.fig) self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.canvas.updateGeometry() df_cm = pd.read_csv('dt_cm_6.csv') im = self.ax1.imshow(df_cm) # We want to show all ticks... self.ax1.set_xticks(np.arange(1, df_cm.shape[0]+1)) self.ax1.set_yticks(np.arange(df_cm.shape[0])) # ... and label them with the respective list entries self.ax1.set_xticklabels(df_cm.columns[1:]) self.ax1.set_yticklabels(df_cm.columns[1:]) # Rotate the tick labels and set their alignment. plt.setp(self.ax1.get_xticklabels(), rotation=45, ha="right",rotation_mode="anchor") # Loop over data dimensions and create text annotations. for i in range(df_cm.shape[0]): for j in range(1, df_cm.shape[0]+1): text = self.ax1.text(j, i, df_cm.iloc[i, j], ha="center", va="center", color="w", fontsize=6) vtitle = "Confusion Matrix" self.ax1.set_title(vtitle) self.ax1.set_xlabel('Predicted label', fontsize=10) self.ax1.set_ylabel('True label', fontsize=10) # Canvas is added to the third group box self.groupBox3Layout.addWidget(self.canvas) # Adding to the main layout the groupboxes self.layout.addWidget(self.groupBox2) self.layout.addWidget(self.groupBox3) self.setCentralWidget(self.main_widget) # Creates the window with all the elements self.resize(600, 500) # Resize the window # show the plot self.fig.tight_layout() self.fig.canvas.draw_idle()
class GraphWParamsClass(QMainWindow): send_fig = pyqtSignal(str) # To manage the signals PyQT manages the communication def __init__(self): #::-------------------------------------------------------- # Initialize the values of the class # Here the class inherits all the attributes and methods from the QMainWindow #::-------------------------------------------------------- super(GraphWParamsClass, self).__init__() self.Title = 'Title : Histogram Target Count ' self.initUi() def initUi(self): #::-------------------------------------------------------------- # We create the type of layout QVBoxLayout (Vertical Layout ) # This type of layout comes from QWidget #::-------------------------------------------------------------- self.v = "With Outliers" self.setWindowTitle(self.Title) self.main_widget = QWidget(self) self.layout = QVBoxLayout(self.main_widget) # Creates vertical layout self.groupBox2 = QGroupBox('With or without Outliers') self.groupBox2Layout = QHBoxLayout() self.groupBox2.setLayout(self.groupBox2Layout) self.groupBox3 = QGroupBox('Graphic') self.groupBox3Layout = QVBoxLayout() self.groupBox3.setLayout(self.groupBox3Layout) # Radio buttons are create to be added to the second group self.b1 = QRadioButton("With Outliers") self.b1.setChecked(True) self.b1.toggled.connect(self.onClicked) self.b2 = QRadioButton("Without Outliers") self.b2.toggled.connect(self.onClicked) self.buttonlabel = QLabel(self.v+' is selected') self.groupBox2Layout.addWidget(self.b1) self.groupBox2Layout.addWidget(self.b2) self.groupBox2Layout.addWidget(self.buttonlabel) # figure and canvas figure to draw the graph is created to self.fig = Figure() self.ax1 = self.fig.add_subplot(111) self.canvas = FigureCanvas(self.fig) self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.canvas.updateGeometry() # Canvas is added to the third group box self.groupBox3Layout.addWidget(self.canvas) # Adding to the main layout the groupboxes self.layout.addWidget(self.groupBox2) self.layout.addWidget(self.groupBox3) self.setCentralWidget(self.main_widget) # Creates the window with all the elements self.resize(600, 500) # Resize the window self.onClicked() def onClicked(self): # Figure is cleared to create the new graph with the choosen parameters self.ax1.clear() train = pd.read_csv('../Final Project/train.csv', parse_dates=["first_active_month"]) # the buttons are inspect to indicate which one is checked. # vcolor is assigned the chosen color if self.b1.isChecked(): self.v = self.b1.text() if self.b2.isChecked(): self.v = self.b2.text() idx = train[np.abs(stats.zscore(train['target'])) > 3].index # Delete these row indexes from dataFrame train.drop(idx, inplace=True) # the label that displays the selected option self.buttonlabel.setText(self.v+' is selected') target = train['target'] self.ax1.hist(target.values, bins=200) vtitle = "Histogram Target Counts" self.ax1.set_title(vtitle) self.ax1.set_xlabel('Count') self.ax1.set_ylabel('Target') self.ax1.grid(True) # show the plot self.fig.tight_layout() self.fig.canvas.draw_idle()
def initUI(self): # 以下是pyqt5初始化设置窗口 self.move(300, 200) self.setFixedSize(350, 450) self.setWindowTitle('设置') self.setWindowIcon(QIcon('GCap.ico')) self.dial1 = QSlider(Qt.Horizontal, self) self.edit1 = QLineEdit(self) self.edit1.setEnabled(False) self.edit1.setMaximumWidth(50) self.lmin1 = QLabel('1316', self) self.lmax1 = QLabel('8996', self) self.dial2 = QSlider(Qt.Horizontal, self) self.edit2 = QLineEdit(self) self.edit2.setEnabled(False) self.edit2.setMaximumWidth(50) self.lmin2 = QLabel('0', self) self.lmax2 = QLabel('65536', self) self.check = QCheckBox(self) self.labelOn = QLabel('打开触发模式', self) self.labelMode = QLabel('触发源', self) self.comboMode = QComboBox(self) self.comboMode.addItem('软触发') self.comboMode.addItem('外触发') self.labelDi = QLabel('触发沿', self) self.comboAct = QComboBox(self) self.comboAct.addItem('上升沿') self.comboAct.addItem('下降沿') groupBox1 = QGroupBox('包大小') gbox1 = QGridLayout() gbox1.addWidget(self.dial1, 0, 0, 1, 9) gbox1.addWidget(self.edit1, 0, 10) gbox1.addWidget(self.lmin1, 1, 0) gbox1.addWidget(self.lmax1, 1, 8) groupBox1.setLayout(gbox1) groupBox2 = QGroupBox('包延迟') gbox2 = QGridLayout() gbox2.addWidget(self.dial2, 0, 0, 1, 9) gbox2.addWidget(self.edit2, 0, 10) gbox2.addWidget(self.lmin2, 1, 0) gbox2.addWidget(self.lmax2, 1, 8) groupBox2.setLayout(gbox2) groupBox3 = QGroupBox('触发') gbox3 = QGridLayout() gbox3.setSpacing(35) gbox3.addWidget(self.check, 0, 0) gbox3.addWidget(self.labelOn, 0, 1) gbox3.addWidget(self.labelMode, 1, 0) gbox3.addWidget(self.comboMode, 1, 1) gbox3.addWidget(self.labelDi, 3, 0) gbox3.addWidget(self.comboAct, 3, 1) gbox3.setColumnStretch(0, 1) gbox3.setColumnStretch(1, 11) groupBox3.setLayout(gbox3) vlayout = QVBoxLayout() vlayout.addWidget(groupBox1) vlayout.addWidget(groupBox2) vlayout.addWidget(groupBox3) vlayout.addStretch() self.setLayout(vlayout) # 获取获取当前相机数据,来初始化窗口界面 self.packetSize = MVGetPacketSize(self.hCam) # 获取当前相机包大小 self.packetDelay = MVGetPacketDelay(self.hCam) # 获取当前相机包延迟 self.mode = MVGetTriggerMode(self.hCam) # 获取当前相机采集模式 self.source = MVGetTriggerSource(self.hCam) # 获取当前相机信号源 self.active = MVGetTriggerActivation( self.hCam) # 当采集模式为外采集时,获取信号的上升沿或者下降沿 self.edit1.setText(str(self.packetSize.psize)) self.edit2.setText(str(self.packetDelay.time_us)) value1 = (self.packetSize.psize - 1316) / (8996 - 1316) * 99 self.dial1.setValue(value1) value2 = self.packetDelay.time_us / 65536 * 99 self.dial2.setValue(value2) if (self.source.source == TriggerSourceEnums.TriggerSource_Software ): # 将当前信号源类型显示在界面上 self.comboMode.setCurrentIndex(0) else: self.comboMode.setCurrentIndex(1) if (self.active.act == TriggerActivationEnums. TriggerActivation_RisingEdge): # 将当前外采集模式信号模式显示在界面上 self.comboAct.setCurrentIndex(0) else: self.comboAct.setCurrentIndex(1) if (self.mode.pMode == TriggerModeEnums.TriggerMode_Off ): # 将当前采集模式开关状态显示在界面上 self.check.setCheckState(Qt.Unchecked) self.comboMode.setEnabled(False) self.comboAct.setEnabled(False) else: self.check.setCheckState(Qt.Checked) self.comboMode.setEnabled(True) if (self.source.source == TriggerSourceEnums.TriggerSource_Software ): # 只有当选择外触发模式时,才可选择触发沿 self.comboAct.setEnabled(False) else: self.comboAct.setEnabled(True) # 以下是到部件的触发事件 self.dial1.valueChanged.connect(self.changeEdit1) self.dial2.valueChanged.connect(self.changeEdit2) self.check.clicked.connect(self.changeStatus) self.comboMode.activated[str].connect(self.changeMode) self.comboAct.activated[str].connect(self.changeAct)
def __init__(self, main_window): super(View, self).__init__() self.main_window = main_window label_path1 = QLabel("Copy till here: ") # Initial Layout # Edit Box self.search_box = QLineEdit() self.search_box.textChanged.connect( partial(setattr, self, "folderpath")) # Push button go_back_button = QPushButton('Back') go_back_button.setToolTip('Show List of items') # Search and button Layout grouping horizontal_groupbox = QGroupBox() layout = QHBoxLayout() layout.addWidget(label_path1) layout.addWidget(self.search_box) layout.addWidget(go_back_button) horizontal_groupbox.setLayout(layout) # Central Layout for data view # Tree View data_groupBox = QGroupBox("Android Directory") self.dataView = QTreeView() self.dataView.setRootIsDecorated(False) self.dataView.setAlternatingRowColors(True) # self.dataView.setSortingEnabled(True) self.dataView.setEditTriggers(QAbstractItemView.NoEditTriggers) data_layout = QHBoxLayout() data_layout.addWidget(self.dataView) data_groupBox.setLayout(data_layout) # Footer Layout label_path2 = QLabel("PATH:") label_path2.setStyleSheet("border: .5px solid black; max-width:50px;") self.path_label_name = QLabel() self.path_label_name.setStyleSheet( "border: 1px solid black; min-width:450px;") self.path_label_name.setWordWrap(True) pull_button = QPushButton("Pull") pull_button.setToolTip("Push this path to desire folder") pull_button.setStyleSheet("min-width: 70px;min-height:15px") footer_groupbox = QGroupBox() footer_layout = QHBoxLayout() footer_layout.addWidget(label_path2) footer_layout.addWidget(self.path_label_name) footer_layout.addWidget(pull_button, alignment=Qt.AlignCenter) footer_groupbox.setLayout(footer_layout) main_layout = QVBoxLayout() main_layout.addWidget(horizontal_groupbox) main_layout.addWidget(data_groupBox) main_layout.addWidget(footer_groupbox) main_window.setLayout(main_layout) # Signals to button for do event and then show in view go_back_button.clicked.connect(self.go_back_signal) self.dataView.clicked.connect(self.single_click_event) self.dataView.doubleClicked.connect(self.double_click_event) pull_button.clicked.connect(self.pull_file_signal)
def additionalSetup(self, plotOptions=[None]): groupBox = QGroupBox("Plot" + str(self.GroupCounter), self) groupLayout = QVBoxLayout(self) #layout to put in group self.comboBox.append(QComboBox(self)) self.comboBox2.append(QComboBox(self)) self.comboBox3.append(QComboBox(self)) self.comboBox4.append(QComboBox(self)) #set options colorOptions = [ 'blue', 'red', 'green', 'cyan', 'magenta', 'yellow', 'black' ] markerOptions = [ '*', 'p', 's', 'h', 'H', 'x', '+', 'D', 'd', '|', '_', 'o', 'v', '^' ] linestyleOptions = ['-', '--', ':', '-.'] #define label self.markersize_label = QLabel("Marker Size: 1", self) self.markerOptions_label = QLabel("Marker type", self) self.colorOptions_label = QLabel("Color", self) self.linestyle_label = QLabel("Linestyle", self) #definde slider self.slider_markersize = QSlider(QtCore.Qt.Horizontal, self) self.slider_markersize.setMaximum(15) self.slider_markersize.setMinimum(1) self.slider_markersize.setValue(3) self.slider_markersize.setSingleStep(1) for option in plotOptions: self.comboBox[self.GroupCounter].addItem(option) for color in colorOptions: self.comboBox2[self.GroupCounter].addItem(color) for marker in markerOptions: self.comboBox3[self.GroupCounter].addItem(marker) for line in linestyleOptions: self.comboBox4[self.GroupCounter].addItem(line) self.radioButton.append( QRadioButton("Run synchronized with Animation", self)) self.radioButton[self.GroupCounter * 2].setChecked(True) self.radioButton.append(QRadioButton("Show Plot", self)) groupLayout.addWidget(self.comboBox[self.GroupCounter]) groupLayout.addWidget(self.colorOptions_label) groupLayout.addWidget(self.comboBox2[self.GroupCounter]) groupLayout.addWidget(self.markerOptions_label) groupLayout.addWidget(self.comboBox3[self.GroupCounter]) groupLayout.addWidget(self.linestyle_label) groupLayout.addWidget(self.comboBox4[self.GroupCounter]) groupLayout.addWidget(self.markersize_label) groupLayout.addWidget(self.slider_markersize) self.markersizeEvent() groupLayout.addWidget(self.radioButton[self.GroupCounter * 2]) groupLayout.addWidget(self.radioButton[(self.GroupCounter * 2) + 1]) groupBox.setLayout(groupLayout) if self.GroupCounter == 0: self.gridLayout_2.addWidget(groupBox, 0, 0) if self.GroupCounter == 1: self.gridLayout_2.addWidget(groupBox, 1, 0) if self.GroupCounter == 2: self.gridLayout_2.addWidget(groupBox, 0, 1) if self.GroupCounter == 3: self.gridLayout_2.addWidget(groupBox, 1, 1) self.GroupCounter += 1 self.refreshScreen()
class MaterialFrame: def __init__(self, parent, box_type='select'): super().__init__() self.parent = parent self.box_type = box_type self.material = MaterialProperties() self.material_name = '' self.boxGroup = QGroupBox('Material Settings', self.parent) self.gridLayout = QGridLayout(self.boxGroup) self.materialBoxGroup = QGroupBox('', self.boxGroup) self.miniLayout = QHBoxLayout(self.materialBoxGroup) self.label_mat_name = QLabel(self.materialBoxGroup) self.label_mat_name.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.material_name_widget = QComboBox() self.miniLayout.addWidget(self.label_mat_name) # self.miniLayout.addWidget(self.material_name_wid) self.materialBoxGroup.setLayout(self.miniLayout) self.label_Density = QLabel('Density (kg/m^3)', self.boxGroup) self.label_Density.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_Density = QLineEdit(self.boxGroup) self.label_spHeat = QLabel('Specific Heat (J/kg.K)', self.boxGroup) self.label_spHeat.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_spHeat = QLineEdit(self.boxGroup) self.label_Conductivity = QLabel('Thermal Conductivity (W/m.K)', self.boxGroup) self.label_Conductivity.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_Conductivity = QLineEdit(self.boxGroup) self.label_meltPt = QLabel('Melting Temperature (K)', self.boxGroup) self.label_meltPt.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_meltPt = QLineEdit(self.boxGroup) self.label_Emissivity = QLabel('Emissivity (0-1)', self.boxGroup) self.label_Emissivity.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_Emissivity = QLineEdit(self.boxGroup) self.label_Reflect = QLabel('Reflectivity (0-1)', self.boxGroup) self.label_Reflect.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.entry_Reflect = QLineEdit(self.boxGroup) self.label_blank = QLabel(' ', self.boxGroup) self.label_blank.setFixedWidth(60) self.gridLayout.addWidget(self.materialBoxGroup, 0, 0, 1, 3) self.gridLayout.addWidget(self.label_Density, 1, 0) self.gridLayout.addWidget(self.entry_Density, 1, 1) self.gridLayout.addWidget(self.label_blank, 1, 2) self.gridLayout.addWidget(self.label_spHeat, 1, 3) self.gridLayout.addWidget(self.entry_spHeat, 1, 4) self.gridLayout.addWidget(self.label_Conductivity, 2, 0) self.gridLayout.addWidget(self.entry_Conductivity, 2, 1) self.gridLayout.addWidget(self.label_meltPt, 2, 3) self.gridLayout.addWidget(self.entry_meltPt, 2, 4) self.gridLayout.addWidget(self.label_Emissivity, 3, 0) self.gridLayout.addWidget(self.entry_Emissivity, 3, 1) self.gridLayout.addWidget(self.label_Reflect, 3, 3) self.gridLayout.addWidget(self.entry_Reflect, 3, 4) self.boxGroup.setLayout(self.gridLayout) if self.box_type == 'entry': self.new_material_entry() else: self.material_select_box() self.material_name_widget.activated[str].connect( self.on_material_select) def material_select_box(self): self.label_mat_name.setText('Select Material') self.material_name_widget = QComboBox(self.materialBoxGroup) self.miniLayout.addWidget(self.material_name_widget) self.update_material_combobox() def new_material_entry(self): self.label_mat_name.setText('Enter Material Name') self.material_name_widget = QLineEdit(self.materialBoxGroup) self.miniLayout.addWidget(self.material_name_widget) def update_material_combobox(self): self.material_name_widget.clear() self.material.get_material_list() self.material_name_widget.addItems(self.material.material_list) def on_material_select(self, text): self.material_name = text self.material.read_from_json(self.material_name) self.entry_Density.setText(str(self.material.density)) self.entry_spHeat.setText(str(self.material.specific_heat)) self.entry_Conductivity.setText(str(self.material.conductivity)) self.entry_meltPt.setText(str(self.material.melting_point)) self.entry_Emissivity.setText(str(self.material.emissivity)) self.entry_Reflect.setText(str(self.material.reflectivity)) print(self.material_name, self.entry_Density.text())
def createGeneralOptionsGroupBox(self): self.generalOptionsGroupBox = QGroupBox("General Options") self.localeCombo = QComboBox() curLocaleIndex = -1 index = 0 for lid in range(QLocale.C, QLocale.LastLanguage + 1): lang = QLocale.Language(lid) countries = QLocale.countriesForLanguage(lang) for country in countries: label = "%s/%s" % (QLocale.languageToString(lang), QLocale.countryToString(country)) locale = QLocale(lang, country) if self.locale().language() == lang and self.locale().country( ) == country: curLocaleIndex = index self.localeCombo.addItem(label, locale) index += 1 if curLocaleIndex != -1: self.localeCombo.setCurrentIndex(curLocaleIndex) self.localeLabel = QLabel("&Locale") self.localeLabel.setBuddy(self.localeCombo) self.firstDayCombo = QComboBox() self.firstDayCombo.addItem("Sunday", Qt.Sunday) self.firstDayCombo.addItem("Monday", Qt.Monday) self.firstDayCombo.addItem("Tuesday", Qt.Tuesday) self.firstDayCombo.addItem("Wednesday", Qt.Wednesday) self.firstDayCombo.addItem("Thursday", Qt.Thursday) self.firstDayCombo.addItem("Friday", Qt.Friday) self.firstDayCombo.addItem("Saturday", Qt.Saturday) self.firstDayLabel = QLabel("Wee&k starts on:") self.firstDayLabel.setBuddy(self.firstDayCombo) self.selectionModeCombo = QComboBox() self.selectionModeCombo.addItem("Single selection", QCalendarWidget.SingleSelection) self.selectionModeCombo.addItem("None", QCalendarWidget.NoSelection) self.selectionModeLabel = QLabel("&Selection mode:") self.selectionModeLabel.setBuddy(self.selectionModeCombo) self.gridCheckBox = QCheckBox("&Grid") self.gridCheckBox.setChecked(self.calendar.isGridVisible()) self.navigationCheckBox = QCheckBox("&Navigation bar") self.navigationCheckBox.setChecked(True) self.horizontalHeaderCombo = QComboBox() self.horizontalHeaderCombo.addItem( "Single letter day names", QCalendarWidget.SingleLetterDayNames) self.horizontalHeaderCombo.addItem("Short day names", QCalendarWidget.ShortDayNames) self.horizontalHeaderCombo.addItem("Long day names", QCalendarWidget.LongDayNames) self.horizontalHeaderCombo.addItem("None", QCalendarWidget.NoHorizontalHeader) self.horizontalHeaderCombo.setCurrentIndex(1) self.horizontalHeaderLabel = QLabel("&Horizontal header:") self.horizontalHeaderLabel.setBuddy(self.horizontalHeaderCombo) self.verticalHeaderCombo = QComboBox() self.verticalHeaderCombo.addItem("ISO week numbers", QCalendarWidget.ISOWeekNumbers) self.verticalHeaderCombo.addItem("None", QCalendarWidget.NoVerticalHeader) self.verticalHeaderLabel = QLabel("&Vertical header:") self.verticalHeaderLabel.setBuddy(self.verticalHeaderCombo) self.localeCombo.currentIndexChanged.connect(self.localeChanged) self.firstDayCombo.currentIndexChanged.connect(self.firstDayChanged) self.selectionModeCombo.currentIndexChanged.connect( self.selectionModeChanged) self.gridCheckBox.toggled.connect(self.calendar.setGridVisible) self.navigationCheckBox.toggled.connect( self.calendar.setNavigationBarVisible) self.horizontalHeaderCombo.currentIndexChanged.connect( self.horizontalHeaderChanged) self.verticalHeaderCombo.currentIndexChanged.connect( self.verticalHeaderChanged) checkBoxLayout = QHBoxLayout() checkBoxLayout.addWidget(self.gridCheckBox) checkBoxLayout.addStretch() checkBoxLayout.addWidget(self.navigationCheckBox) outerLayout = QGridLayout() outerLayout.addWidget(self.localeLabel, 0, 0) outerLayout.addWidget(self.localeCombo, 0, 1) outerLayout.addWidget(self.firstDayLabel, 1, 0) outerLayout.addWidget(self.firstDayCombo, 1, 1) outerLayout.addWidget(self.selectionModeLabel, 2, 0) outerLayout.addWidget(self.selectionModeCombo, 2, 1) outerLayout.addLayout(checkBoxLayout, 3, 0, 1, 2) outerLayout.addWidget(self.horizontalHeaderLabel, 4, 0) outerLayout.addWidget(self.horizontalHeaderCombo, 4, 1) outerLayout.addWidget(self.verticalHeaderLabel, 5, 0) outerLayout.addWidget(self.verticalHeaderCombo, 5, 1) self.generalOptionsGroupBox.setLayout(outerLayout) self.firstDayChanged(self.firstDayCombo.currentIndex()) self.selectionModeChanged(self.selectionModeCombo.currentIndex()) self.horizontalHeaderChanged(self.horizontalHeaderCombo.currentIndex()) self.verticalHeaderChanged(self.verticalHeaderCombo.currentIndex())
class Window(QWidget): def __init__(self): super(Window, self).__init__() self.createPreviewGroupBox() self.createGeneralOptionsGroupBox() self.createDatesGroupBox() self.createTextFormatsGroupBox() layout = QGridLayout() layout.addWidget(self.previewGroupBox, 0, 0) layout.addWidget(self.generalOptionsGroupBox, 0, 1) layout.addWidget(self.datesGroupBox, 1, 0) layout.addWidget(self.textFormatsGroupBox, 1, 1) layout.setSizeConstraint(QLayout.SetFixedSize) self.setLayout(layout) self.previewLayout.setRowMinimumHeight( 0, self.calendar.sizeHint().height()) self.previewLayout.setColumnMinimumWidth( 0, self.calendar.sizeHint().width()) self.setWindowTitle("Calendar Widget") def localeChanged(self, index): self.calendar.setLocale(self.localeCombo.itemData(index)) def firstDayChanged(self, index): self.calendar.setFirstDayOfWeek( Qt.DayOfWeek(self.firstDayCombo.itemData(index))) def selectionModeChanged(self, index): self.calendar.setSelectionMode( QCalendarWidget.SelectionMode( self.selectionModeCombo.itemData(index))) def horizontalHeaderChanged(self, index): self.calendar.setHorizontalHeaderFormat( QCalendarWidget.HorizontalHeaderFormat( self.horizontalHeaderCombo.itemData(index))) def verticalHeaderChanged(self, index): self.calendar.setVerticalHeaderFormat( QCalendarWidget.VerticalHeaderFormat( self.verticalHeaderCombo.itemData(index))) def selectedDateChanged(self): self.currentDateEdit.setDate(self.calendar.selectedDate()) def minimumDateChanged(self, date): self.calendar.setMinimumDate(date) self.maximumDateEdit.setDate(self.calendar.maximumDate()) def maximumDateChanged(self, date): self.calendar.setMaximumDate(date) self.minimumDateEdit.setDate(self.calendar.minimumDate()) def weekdayFormatChanged(self): format = QTextCharFormat() format.setForeground( Qt.GlobalColor( self.weekdayColorCombo.itemData( self.weekdayColorCombo.currentIndex()))) self.calendar.setWeekdayTextFormat(Qt.Monday, format) self.calendar.setWeekdayTextFormat(Qt.Tuesday, format) self.calendar.setWeekdayTextFormat(Qt.Wednesday, format) self.calendar.setWeekdayTextFormat(Qt.Thursday, format) self.calendar.setWeekdayTextFormat(Qt.Friday, format) def weekendFormatChanged(self): format = QTextCharFormat() format.setForeground( Qt.GlobalColor( self.weekendColorCombo.itemData( self.weekendColorCombo.currentIndex()))) self.calendar.setWeekdayTextFormat(Qt.Saturday, format) self.calendar.setWeekdayTextFormat(Qt.Sunday, format) def reformatHeaders(self): text = self.headerTextFormatCombo.currentText() format = QTextCharFormat() if text == "Bold": format.setFontWeight(QFont.Bold) elif text == "Italic": format.setFontItalic(True) elif text == "Green": format.setForeground(Qt.green) self.calendar.setHeaderTextFormat(format) def reformatCalendarPage(self): if self.firstFridayCheckBox.isChecked(): firstFriday = QDate(self.calendar.yearShown(), self.calendar.monthShown(), 1) while firstFriday.dayOfWeek() != Qt.Friday: firstFriday = firstFriday.addDays(1) firstFridayFormat = QTextCharFormat() firstFridayFormat.setForeground(Qt.blue) self.calendar.setDateTextFormat(firstFriday, firstFridayFormat) # May 1st in Red takes precedence. if self.mayFirstCheckBox.isChecked(): mayFirst = QDate(self.calendar.yearShown(), 5, 1) mayFirstFormat = QTextCharFormat() mayFirstFormat.setForeground(Qt.red) self.calendar.setDateTextFormat(mayFirst, mayFirstFormat) def createPreviewGroupBox(self): self.previewGroupBox = QGroupBox("Preview") self.calendar = QCalendarWidget() self.calendar.setMinimumDate(QDate(1900, 1, 1)) self.calendar.setMaximumDate(QDate(3000, 1, 1)) self.calendar.setGridVisible(True) self.calendar.currentPageChanged.connect(self.reformatCalendarPage) self.previewLayout = QGridLayout() self.previewLayout.addWidget(self.calendar, 0, 0, Qt.AlignCenter) self.previewGroupBox.setLayout(self.previewLayout) def createGeneralOptionsGroupBox(self): self.generalOptionsGroupBox = QGroupBox("General Options") self.localeCombo = QComboBox() curLocaleIndex = -1 index = 0 for lid in range(QLocale.C, QLocale.LastLanguage + 1): lang = QLocale.Language(lid) countries = QLocale.countriesForLanguage(lang) for country in countries: label = "%s/%s" % (QLocale.languageToString(lang), QLocale.countryToString(country)) locale = QLocale(lang, country) if self.locale().language() == lang and self.locale().country( ) == country: curLocaleIndex = index self.localeCombo.addItem(label, locale) index += 1 if curLocaleIndex != -1: self.localeCombo.setCurrentIndex(curLocaleIndex) self.localeLabel = QLabel("&Locale") self.localeLabel.setBuddy(self.localeCombo) self.firstDayCombo = QComboBox() self.firstDayCombo.addItem("Sunday", Qt.Sunday) self.firstDayCombo.addItem("Monday", Qt.Monday) self.firstDayCombo.addItem("Tuesday", Qt.Tuesday) self.firstDayCombo.addItem("Wednesday", Qt.Wednesday) self.firstDayCombo.addItem("Thursday", Qt.Thursday) self.firstDayCombo.addItem("Friday", Qt.Friday) self.firstDayCombo.addItem("Saturday", Qt.Saturday) self.firstDayLabel = QLabel("Wee&k starts on:") self.firstDayLabel.setBuddy(self.firstDayCombo) self.selectionModeCombo = QComboBox() self.selectionModeCombo.addItem("Single selection", QCalendarWidget.SingleSelection) self.selectionModeCombo.addItem("None", QCalendarWidget.NoSelection) self.selectionModeLabel = QLabel("&Selection mode:") self.selectionModeLabel.setBuddy(self.selectionModeCombo) self.gridCheckBox = QCheckBox("&Grid") self.gridCheckBox.setChecked(self.calendar.isGridVisible()) self.navigationCheckBox = QCheckBox("&Navigation bar") self.navigationCheckBox.setChecked(True) self.horizontalHeaderCombo = QComboBox() self.horizontalHeaderCombo.addItem( "Single letter day names", QCalendarWidget.SingleLetterDayNames) self.horizontalHeaderCombo.addItem("Short day names", QCalendarWidget.ShortDayNames) self.horizontalHeaderCombo.addItem("Long day names", QCalendarWidget.LongDayNames) self.horizontalHeaderCombo.addItem("None", QCalendarWidget.NoHorizontalHeader) self.horizontalHeaderCombo.setCurrentIndex(1) self.horizontalHeaderLabel = QLabel("&Horizontal header:") self.horizontalHeaderLabel.setBuddy(self.horizontalHeaderCombo) self.verticalHeaderCombo = QComboBox() self.verticalHeaderCombo.addItem("ISO week numbers", QCalendarWidget.ISOWeekNumbers) self.verticalHeaderCombo.addItem("None", QCalendarWidget.NoVerticalHeader) self.verticalHeaderLabel = QLabel("&Vertical header:") self.verticalHeaderLabel.setBuddy(self.verticalHeaderCombo) self.localeCombo.currentIndexChanged.connect(self.localeChanged) self.firstDayCombo.currentIndexChanged.connect(self.firstDayChanged) self.selectionModeCombo.currentIndexChanged.connect( self.selectionModeChanged) self.gridCheckBox.toggled.connect(self.calendar.setGridVisible) self.navigationCheckBox.toggled.connect( self.calendar.setNavigationBarVisible) self.horizontalHeaderCombo.currentIndexChanged.connect( self.horizontalHeaderChanged) self.verticalHeaderCombo.currentIndexChanged.connect( self.verticalHeaderChanged) checkBoxLayout = QHBoxLayout() checkBoxLayout.addWidget(self.gridCheckBox) checkBoxLayout.addStretch() checkBoxLayout.addWidget(self.navigationCheckBox) outerLayout = QGridLayout() outerLayout.addWidget(self.localeLabel, 0, 0) outerLayout.addWidget(self.localeCombo, 0, 1) outerLayout.addWidget(self.firstDayLabel, 1, 0) outerLayout.addWidget(self.firstDayCombo, 1, 1) outerLayout.addWidget(self.selectionModeLabel, 2, 0) outerLayout.addWidget(self.selectionModeCombo, 2, 1) outerLayout.addLayout(checkBoxLayout, 3, 0, 1, 2) outerLayout.addWidget(self.horizontalHeaderLabel, 4, 0) outerLayout.addWidget(self.horizontalHeaderCombo, 4, 1) outerLayout.addWidget(self.verticalHeaderLabel, 5, 0) outerLayout.addWidget(self.verticalHeaderCombo, 5, 1) self.generalOptionsGroupBox.setLayout(outerLayout) self.firstDayChanged(self.firstDayCombo.currentIndex()) self.selectionModeChanged(self.selectionModeCombo.currentIndex()) self.horizontalHeaderChanged(self.horizontalHeaderCombo.currentIndex()) self.verticalHeaderChanged(self.verticalHeaderCombo.currentIndex()) def createDatesGroupBox(self): self.datesGroupBox = QGroupBox(self.tr("Dates")) self.minimumDateEdit = QDateEdit() self.minimumDateEdit.setDisplayFormat('MMM d yyyy') self.minimumDateEdit.setDateRange(self.calendar.minimumDate(), self.calendar.maximumDate()) self.minimumDateEdit.setDate(self.calendar.minimumDate()) self.minimumDateLabel = QLabel("&Minimum Date:") self.minimumDateLabel.setBuddy(self.minimumDateEdit) self.currentDateEdit = QDateEdit() self.currentDateEdit.setDisplayFormat('MMM d yyyy') self.currentDateEdit.setDate(self.calendar.selectedDate()) self.currentDateEdit.setDateRange(self.calendar.minimumDate(), self.calendar.maximumDate()) self.currentDateLabel = QLabel("&Current Date:") self.currentDateLabel.setBuddy(self.currentDateEdit) self.maximumDateEdit = QDateEdit() self.maximumDateEdit.setDisplayFormat('MMM d yyyy') self.maximumDateEdit.setDateRange(self.calendar.minimumDate(), self.calendar.maximumDate()) self.maximumDateEdit.setDate(self.calendar.maximumDate()) self.maximumDateLabel = QLabel("Ma&ximum Date:") self.maximumDateLabel.setBuddy(self.maximumDateEdit) self.currentDateEdit.dateChanged.connect(self.calendar.setSelectedDate) self.calendar.selectionChanged.connect(self.selectedDateChanged) self.minimumDateEdit.dateChanged.connect(self.minimumDateChanged) self.maximumDateEdit.dateChanged.connect(self.maximumDateChanged) dateBoxLayout = QGridLayout() dateBoxLayout.addWidget(self.currentDateLabel, 1, 0) dateBoxLayout.addWidget(self.currentDateEdit, 1, 1) dateBoxLayout.addWidget(self.minimumDateLabel, 0, 0) dateBoxLayout.addWidget(self.minimumDateEdit, 0, 1) dateBoxLayout.addWidget(self.maximumDateLabel, 2, 0) dateBoxLayout.addWidget(self.maximumDateEdit, 2, 1) dateBoxLayout.setRowStretch(3, 1) self.datesGroupBox.setLayout(dateBoxLayout) def createTextFormatsGroupBox(self): self.textFormatsGroupBox = QGroupBox("Text Formats") self.weekdayColorCombo = self.createColorComboBox() self.weekdayColorCombo.setCurrentIndex( self.weekdayColorCombo.findText("Black")) self.weekdayColorLabel = QLabel("&Weekday color:") self.weekdayColorLabel.setBuddy(self.weekdayColorCombo) self.weekendColorCombo = self.createColorComboBox() self.weekendColorCombo.setCurrentIndex( self.weekendColorCombo.findText("Red")) self.weekendColorLabel = QLabel("Week&end color:") self.weekendColorLabel.setBuddy(self.weekendColorCombo) self.headerTextFormatCombo = QComboBox() self.headerTextFormatCombo.addItem("Bold") self.headerTextFormatCombo.addItem("Italic") self.headerTextFormatCombo.addItem("Plain") self.headerTextFormatLabel = QLabel("&Header text:") self.headerTextFormatLabel.setBuddy(self.headerTextFormatCombo) self.firstFridayCheckBox = QCheckBox("&First Friday in blue") self.mayFirstCheckBox = QCheckBox("May &1 in red") self.weekdayColorCombo.currentIndexChanged.connect( self.weekdayFormatChanged) self.weekendColorCombo.currentIndexChanged.connect( self.weekendFormatChanged) self.headerTextFormatCombo.currentIndexChanged.connect( self.reformatHeaders) self.firstFridayCheckBox.toggled.connect(self.reformatCalendarPage) self.mayFirstCheckBox.toggled.connect(self.reformatCalendarPage) checkBoxLayout = QHBoxLayout() checkBoxLayout.addWidget(self.firstFridayCheckBox) checkBoxLayout.addStretch() checkBoxLayout.addWidget(self.mayFirstCheckBox) outerLayout = QGridLayout() outerLayout.addWidget(self.weekdayColorLabel, 0, 0) outerLayout.addWidget(self.weekdayColorCombo, 0, 1) outerLayout.addWidget(self.weekendColorLabel, 1, 0) outerLayout.addWidget(self.weekendColorCombo, 1, 1) outerLayout.addWidget(self.headerTextFormatLabel, 2, 0) outerLayout.addWidget(self.headerTextFormatCombo, 2, 1) outerLayout.addLayout(checkBoxLayout, 3, 0, 1, 2) self.textFormatsGroupBox.setLayout(outerLayout) self.weekdayFormatChanged() self.weekendFormatChanged() self.reformatHeaders() self.reformatCalendarPage() def createColorComboBox(self): comboBox = QComboBox() comboBox.addItem("Red", Qt.red) comboBox.addItem("Blue", Qt.blue) comboBox.addItem("Black", Qt.black) comboBox.addItem("Magenta", Qt.magenta) return comboBox
class MyApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): vbox = QVBoxLayout() vbox.addWidget(self.Setting()) vbox.addWidget(self.Input()) vbox.addWidget(self.Output()) self.setLayout(vbox) self.setWindowTitle('KAI Testcase Recommandation Program') self.resize(800, 800) self.center() self.show() def center(self): qr = self.frameGeometry() cp = QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft()) def Setting(self): groupbox = QGroupBox('Setting') self.groupbox1 = QGroupBox('검색 범위') self.groupbox1.setFlat(True) self.groupbox2 = QGroupBox('결과 갯수') self.groupbox2.setFlat(True) self.groupbox1.setCheckable(True) self.groupbox1.setChecked(False) self.groupbox2.setCheckable(True) self.groupbox2.setChecked(False) self.cb1 = QComboBox(self) self.cb1.addItem('3.2.11') self.cb1.addItem('3.2.12') self.cb1.addItem('3.2.13') self.cb1.addItem('3.2.14') label1 = QLabel('~', self) self.cb2 = QComboBox(self) self.cb2.addItem('3.2.11') self.cb2.addItem('3.2.12') self.cb2.addItem('3.2.13') self.cb2.addItem('3.2.14') hbox1 = QHBoxLayout() hbox1.addWidget(self.cb1) hbox1.addWidget(label1) hbox1.addWidget(self.cb2) self.groupbox1.setLayout(hbox1) self.cb2.setCurrentText('3.2.14') self.SearchR11 = int(self.cb1.currentText()[0]) self.SearchR12 = int(self.cb1.currentText()[2]) self.SearchR13 = int(self.cb1.currentText()[4:]) self.SearchR21 = 3 self.SearchR22 = 2 self.SearchR23 = 14 self.qle3 = QLineEdit(self) self.qle3.setText('1') label2 = QLabel('개', self) self.outputnum = int(self.qle3.text()) hbox2 = QHBoxLayout() hbox2.addWidget(self.qle3) hbox2.addWidget(label2) self.groupbox2.setLayout(hbox2) self.setBtn = QPushButton('Set', self) self.setBtn.setCheckable(True) self.setBtn.clicked.connect(self.Set_clicked) hbox = QHBoxLayout() hbox.addWidget(self.groupbox1) hbox.addWidget(self.groupbox2) hbox.addStretch(1) hbox.addWidget(self.setBtn) groupbox.setLayout(hbox) return groupbox def Set_clicked(self): if (self.groupbox1.isChecked()): self.cb1.currentTextChanged self.cb2.currentTextChanged self.SearchR11 = int(self.cb1.currentText()[0]) self.SearchR12 = int(self.cb1.currentText()[2]) self.SearchR13 = int(self.cb1.currentText()[4:]) self.SearchR21 = int(self.cb2.currentText()[0]) self.SearchR22 = int(self.cb2.currentText()[2]) self.SearchR23 = int(self.cb2.currentText()[4:]) if (self.SearchR13 > self.SearchR23): print("범위를 다시 설정하세요.") QMessageBox.about(self, '범위설정 오류', '범위를 다시 설정해주세요.') else: print("Search Range1 is : ", self.SearchR11) print("Search Range1 is : ", self.SearchR12) print("Search Range1 is : ", self.SearchR13) print("Search Range2 is : ", self.SearchR21) print("Search Range2 is : ", self.SearchR22) print("Search Range2 is : ", self.SearchR23) else: self.SearchR11 = 3 self.SearchR12 = 2 self.SearchR13 = 11 self.SearchR21 = 3 self.SearchR22 = 2 self.SearchR23 = 14 print("Search Range1 is : ", self.SearchR11) print("Search Range1 is : ", self.SearchR12) print("Search Range1 is : ", self.SearchR13) print("Search Range2 is : ", self.SearchR21) print("Search Range2 is : ", self.SearchR22) print("Search Range2 is : ", self.SearchR23) if (self.groupbox2.isChecked()): try: self.outputnum = int(self.qle3.text()) print("outputnum is : ", self.outputnum) except: QMessageBox.about(self, '결과개수오류', '숫자를 입력해 주세요.') else: self.qle3.setText('1') self.outputnum = int(self.qle3.text()) print("outputnum is : ", self.outputnum) print('Set') def Input(self): groupbox = QGroupBox('Input') hbox1 = QHBoxLayout() self.I_button = QRadioButton('Internal Input') self.E_button = QRadioButton('External Input') self.I_button.setChecked(True) self.I_button.clicked.connect(self.I_clicked) self.E_button.clicked.connect(self.E_clicked) hbox1.addWidget(self.I_button) hbox1.addWidget(self.E_button) Tableinputbox = QHBoxLayout() self.table = QTableWidget() Tableinputbox.addWidget(self.table) self.table.clear() self.table.setFixedHeight(90) self.table.setRowCount(1) self.table.setColumnCount(4) column_headers = [ 'INPUT SOURCE', 'SIGNAL DESCRIPTION', 'TYPE', 'PACKET ID' ] self.table.setHorizontalHeaderLabels(column_headers) self.table.setColumnWidth(1, 361) self.table.setColumnWidth(2, 80) self.table.setColumnWidth(3, 80) hbox3 = QHBoxLayout() self.searchBtn = QPushButton('Search') self.searchBtn.clicked.connect(self.Search_clicked) hbox3.addStretch(2) hbox3.addWidget(self.searchBtn) vbox = QVBoxLayout() vbox.addLayout(hbox1) vbox.addLayout(Tableinputbox) vbox.addLayout(hbox3) groupbox.setLayout(vbox) groupbox.setFixedHeight(200) return groupbox def I_clicked(self): print('internal') self.table.clear() self.table.setFixedHeight(90) self.table.setRowCount(1) self.table.setColumnCount(4) column_headers = [ 'INPUT SOURCE', 'SIGNAL DESCRIPTION', 'TYPE', 'PACKET ID' ] self.table.setHorizontalHeaderLabels(column_headers) self.table.setColumnWidth(1, 361) self.table.setColumnWidth(2, 80) self.table.setColumnWidth(3, 80) def E_clicked(self): print('external') self.table.clear() self.table.setFixedHeight(90) self.table.setRowCount(1) self.table.setColumnCount(3) column_headers = [ 'INPUT SOURCE', 'SIGNAL DESCRIPTION', 'ICD SIGNAL SPECIFICATION' ] self.table.setHorizontalHeaderLabels(column_headers) self.table.setColumnWidth(1, 361) self.table.setColumnWidth(2, 160) def Search_clicked(self): print("Search") self.moreCnt = 0 self.loopCnt = 0 outputnum = self.outputnum row = self.table.rowCount() column = self.table.columnCount() inputData = [] for x in range(0, row, 1): for y in range(0, column, 1): if self.table.item(x, y) is None: text = '' else: text = self.table.item(x, y).text() inputData.append(text) print(inputData) self.testInput1 = inputData[0] self.testInput2 = inputData[1] self.testInput3 = inputData[2] if (inputData == ['', '', '', ''] or inputData == ['', '', '']): self.inputIsEmpty() else: self.outputTable.clearContents() if (column == 3): similarityClass = ExternalSimilarity() tcdf = pd.read_excel(os.getcwd() + '/external_testcase.xlsx') elif (column == 4): similarityClass = InternalSimilarity() tcdf = pd.read_excel(os.getcwd() + '/internal_testcase.xlsx') self.testInput4 = inputData[3] self.outputTable.setRowCount(1) self.outputTable.setColumnCount(3) reqSim = similarityClass.checkREQSimilarity(inputData) tcSim = similarityClass.checkTCSimilarity(inputData) resultSim = similarityClass.resultSimilarity(reqSim, tcSim) df2 = pd.merge( resultSim, tcdf, on=['Range1', 'Range2', 'Range3', 'Req Index', 'TC Index'], how="outer", right_index=False) df2 = df2.fillna("-") print("콜럼명 : ", list(df2)) self.arr = df2.values self.x = 0 self.rangedTC = [] for x in range(0, len(df2.index), 1): arr2 = self.arr[x][:] if (arr2[0] >= self.SearchR11 and arr2[1] >= self.SearchR12 and arr2[2] >= self.SearchR13 and arr2[0] <= self.SearchR21 and arr2[1] <= self.SearchR22 and arr2[2] <= self.SearchR23): self.rangedTC.append(arr2) print("arr3 = ", self.rangedTC[0][7]) if (self.outputnum > len(self.rangedTC)): outputnum = len(self.rangedTC) for self.x in range(0, outputnum, 1): TestAction = self.rangedTC[self.x][7] ExpectedResult = self.rangedTC[self.x][8] PassFail = self.rangedTC[self.x][9] rowPosition = self.outputTable.rowCount() if (rowPosition < outputnum): self.outputTable.insertRow(rowPosition) self.outputTable.setItem(self.x, 0, QTableWidgetItem(TestAction)) self.outputTable.setItem(self.x, 1, QTableWidgetItem(ExpectedResult)) self.outputTable.setItem(self.x, 2, QTableWidgetItem(PassFail)) def inputIsEmpty(self): QMessageBox.warning( self, '경고', '입력 table에 값을 입력해주십시오.', ) def Output(self): groupbox = QGroupBox('Output') vbox = QVBoxLayout() vbox.addWidget(self.OuputTable()) hbox = QHBoxLayout() self.moreBtn = QPushButton('More') self.saveBtn = QPushButton('Save') self.moreBtn.clicked.connect(self.More_clicked) self.saveBtn.clicked.connect(self.Save_clicked) hbox.addStretch(2) hbox.addWidget(self.moreBtn) hbox.addWidget(self.saveBtn) vbox.addLayout(hbox) groupbox.setLayout(vbox) return groupbox def More_clicked(self): print("more") self.moreCnt = self.moreCnt + 1 self.totalCnt = self.outputnum + self.moreCnt - 1 if (self.totalCnt >= len(self.rangedTC)): QMessageBox.warning( self, '경고', '모든 testcase를 표시하였습니다.', ) return 0 TestAction = self.rangedTC[self.totalCnt][7] ExpectedResult = self.rangedTC[self.totalCnt][8] PassFail = self.rangedTC[self.totalCnt][9] rowPosition = self.outputTable.rowCount() self.outputTable.insertRow(rowPosition) self.outputTable.setItem(self.totalCnt, 0, QTableWidgetItem(TestAction)) self.outputTable.setItem(self.totalCnt, 1, QTableWidgetItem(ExpectedResult)) self.outputTable.setItem(self.totalCnt, 2, QTableWidgetItem(PassFail)) def Save_clicked(self): print("save") TestAction = [] ExpectedResult = [] PassFail = [] for x in range(0, self.totalCnt + 1, 1): text1 = self.outputTable.item(x, 0).text() text2 = self.outputTable.item(x, 1).text() text3 = self.outputTable.item(x, 2).text() TestAction.append(text1) ExpectedResult.append(text2) PassFail.append(text3) print("TestAction = ", TestAction) print("Expected Result = ", ExpectedResult) print("PAssFail = ", PassFail) df = pd.DataFrame({ 'Test Action': TestAction, 'Expected Result': ExpectedResult, 'Pass/Fail': PassFail }) print("df = ", df) SaveWindow(self, df) def OuputTable(self): box = QGroupBox() self.outputTable = QTableWidget() self.outputTable.setRowCount(1) self.outputTable.setColumnCount(3) column_headers = ['Test Action', 'Expected Result', 'Pass/Fail'] self.outputTable.setHorizontalHeaderLabels(column_headers) self.outputTable.setColumnWidth(0, 260) self.outputTable.setColumnWidth(1, 281) self.outputTable.setColumnWidth(2, 80) vbox = QVBoxLayout() vbox.addWidget(self.outputTable) box.setLayout(vbox) return box
def Setting(self): groupbox = QGroupBox('Setting') self.groupbox1 = QGroupBox('검색 범위') self.groupbox1.setFlat(True) self.groupbox2 = QGroupBox('결과 갯수') self.groupbox2.setFlat(True) self.groupbox1.setCheckable(True) self.groupbox1.setChecked(False) self.groupbox2.setCheckable(True) self.groupbox2.setChecked(False) self.cb1 = QComboBox(self) self.cb1.addItem('3.2.11') self.cb1.addItem('3.2.12') self.cb1.addItem('3.2.13') self.cb1.addItem('3.2.14') label1 = QLabel('~', self) self.cb2 = QComboBox(self) self.cb2.addItem('3.2.11') self.cb2.addItem('3.2.12') self.cb2.addItem('3.2.13') self.cb2.addItem('3.2.14') hbox1 = QHBoxLayout() hbox1.addWidget(self.cb1) hbox1.addWidget(label1) hbox1.addWidget(self.cb2) self.groupbox1.setLayout(hbox1) self.cb2.setCurrentText('3.2.14') self.SearchR11 = int(self.cb1.currentText()[0]) self.SearchR12 = int(self.cb1.currentText()[2]) self.SearchR13 = int(self.cb1.currentText()[4:]) self.SearchR21 = 3 self.SearchR22 = 2 self.SearchR23 = 14 self.qle3 = QLineEdit(self) self.qle3.setText('1') label2 = QLabel('개', self) self.outputnum = int(self.qle3.text()) hbox2 = QHBoxLayout() hbox2.addWidget(self.qle3) hbox2.addWidget(label2) self.groupbox2.setLayout(hbox2) self.setBtn = QPushButton('Set', self) self.setBtn.setCheckable(True) self.setBtn.clicked.connect(self.Set_clicked) hbox = QHBoxLayout() hbox.addWidget(self.groupbox1) hbox.addWidget(self.groupbox2) hbox.addStretch(1) hbox.addWidget(self.setBtn) groupbox.setLayout(hbox) return groupbox
class RunBackupWidget(QWidget): def __init__(self): super().__init__() self.most_recent_backup = None self.top_level_layout = QVBoxLayout() self.setLayout(self.top_level_layout) # controls across the top self.controls_widget = QWidget() self.controls_layout = QHBoxLayout() self.controls_widget.setLayout(self.controls_layout) self.start_button = QPushButton("Start") self.start_button.clicked.connect(self.start) self.controls_layout.addWidget(self.start_button) self.stop_button = QPushButton("Stop") self.stop_button.clicked.connect(self.stop) self.controls_layout.addWidget(self.stop_button) self.controls_layout.addWidget(QLabel("Next backup:")) self.countdown_text = QLabel() self.controls_layout.addWidget(self.countdown_text) self.controls_layout.addStretch() # status self.status_widget = QGroupBox("Status") self.status_layout = QHBoxLayout() self.status_widget.setLayout(self.status_layout) self.backup_status = {} self.backup_engines = {} self.run_all = RunAll(self) for backup_type in BackupTypes: self.backup_status[backup_type] = BackupWidget(backup_type) display_boxes = self.backup_status[backup_type].display_boxes self.backup_engines[backup_type] = backup_classes[backup_type]( UITypes.gui, display_boxes[DisplayTypes.log].append_text, display_boxes[DisplayTypes.warnings].append_text, display_boxes[DisplayTypes.errors].append_text ) self.status_layout.addWidget(self.backup_status[backup_type]) # add all the widgets to the top level layout self.top_level_layout.addWidget(self.controls_widget) self.top_level_layout.addWidget(self.status_widget) self.restore_state() def start(self): self.most_recent_backup = int(round(datetime.now().timestamp())) # set after all runs successfully finished preferences = get_gui_preferences() if preferences.backup_directory is None: log.error("backup directory not set") else: self.run_all.start() def stop(self): for backup_type in self.backup_engines: self.backup_engines[backup_type].terminate() def get_layout_key(self, backup_type: BackupTypes, display_type: DisplayTypes, height_width: str): return f"{backup_type.name}_{display_type.name}_{height_width}" def save_state(self): preferences = get_gui_preferences() for backup_type in BackupTypes: for display_type in DisplayTypes: setattr(preferences, self.get_layout_key(backup_type, display_type, "height"), self.backup_status[backup_type].display_boxes[display_type].height()) setattr(preferences, self.get_layout_key(backup_type, display_type, "width"), self.backup_status[backup_type].display_boxes[display_type].width()) preferences.most_recent_backup = self.most_recent_backup def restore_state(self): preferences = get_gui_preferences() for backup_type in BackupTypes: for display_type in DisplayTypes: if (height := getattr(preferences, self.get_layout_key(backup_type, display_type, "height"), 0)) is not None: height = int(height) if (width := getattr(preferences, self.get_layout_key(backup_type, display_type, "width"), 0)) is not None: width = int(width) # make sure all windows come up as visible, even if not set or the user has reduced them to zero if height is not None and height > 0 and width is not None and width > 0: self.backup_status[backup_type].display_boxes[display_type].resize(width, height)
def request_trezor_init_settings(self, wizard, method, device_id): vbox = QVBoxLayout() next_enabled = True devmgr = self.device_manager() client = devmgr.client_by_id(device_id) if not client: raise Exception(_("The device was disconnected.")) model = client.get_trezor_model() fw_version = client.client.version capabilities = client.client.features.capabilities have_shamir = Capability.Shamir in capabilities # label label = QLabel(_("Enter a label to name your device:")) name = QLineEdit() hl = QHBoxLayout() hl.addWidget(label) hl.addWidget(name) hl.addStretch(1) vbox.addLayout(hl) # Backup type gb_backuptype = QGroupBox() hbox_backuptype = QHBoxLayout() gb_backuptype.setLayout(hbox_backuptype) vbox.addWidget(gb_backuptype) gb_backuptype.setTitle(_('Select backup type:')) bg_backuptype = QButtonGroup() rb_single = QRadioButton(gb_backuptype) rb_single.setText(_('Single seed (BIP39)')) bg_backuptype.addButton(rb_single) bg_backuptype.setId(rb_single, BackupType.Bip39) hbox_backuptype.addWidget(rb_single) rb_single.setChecked(True) rb_shamir = QRadioButton(gb_backuptype) rb_shamir.setText(_('Shamir')) bg_backuptype.addButton(rb_shamir) bg_backuptype.setId(rb_shamir, BackupType.Slip39_Basic) hbox_backuptype.addWidget(rb_shamir) rb_shamir.setEnabled(Capability.Shamir in capabilities) rb_shamir.setVisible(False) # visible with "expert settings" rb_shamir_groups = QRadioButton(gb_backuptype) rb_shamir_groups.setText(_('Super Shamir')) bg_backuptype.addButton(rb_shamir_groups) bg_backuptype.setId(rb_shamir_groups, BackupType.Slip39_Advanced) hbox_backuptype.addWidget(rb_shamir_groups) rb_shamir_groups.setEnabled(Capability.ShamirGroups in capabilities) rb_shamir_groups.setVisible(False) # visible with "expert settings" # word count word_count_buttons = {} gb_numwords = QGroupBox() hbox1 = QHBoxLayout() gb_numwords.setLayout(hbox1) vbox.addWidget(gb_numwords) gb_numwords.setTitle(_("Select seed/share length:")) bg_numwords = QButtonGroup() for count in (12, 18, 20, 24, 33): rb = QRadioButton(gb_numwords) word_count_buttons[count] = rb rb.setText(_("{:d} words").format(count)) bg_numwords.addButton(rb) bg_numwords.setId(rb, count) hbox1.addWidget(rb) rb.setChecked(True) def configure_word_counts(): if model == "1": checked_wordcount = 24 else: checked_wordcount = 12 if method == TIM_RECOVER: if have_shamir: valid_word_counts = (12, 18, 20, 24, 33) else: valid_word_counts = (12, 18, 24) elif rb_single.isChecked(): valid_word_counts = (12, 18, 24) gb_numwords.setTitle(_('Select seed length:')) else: valid_word_counts = (20, 33) checked_wordcount = 20 gb_numwords.setTitle(_('Select share length:')) word_count_buttons[checked_wordcount].setChecked(True) for c, btn in word_count_buttons.items(): btn.setVisible(c in valid_word_counts) bg_backuptype.buttonClicked.connect(configure_word_counts) configure_word_counts() # set up conditional visibility: # 1. backup_type is only visible when creating new seed gb_backuptype.setVisible(method == TIM_NEW) # 2. word_count is not visible when recovering on TT if method == TIM_RECOVER and model != "1": gb_numwords.setVisible(False) # PIN cb_pin = QCheckBox(_('Enable PIN protection')) cb_pin.setChecked(True) vbox.addWidget(WWLabel(RECOMMEND_PIN)) vbox.addWidget(cb_pin) # "expert settings" button expert_vbox = QVBoxLayout() expert_widget = QWidget() expert_widget.setLayout(expert_vbox) expert_widget.setVisible(False) expert_button = QPushButton(_("Show expert settings")) def show_expert_settings(): expert_button.setVisible(False) expert_widget.setVisible(True) rb_shamir.setVisible(True) rb_shamir_groups.setVisible(True) expert_button.clicked.connect(show_expert_settings) vbox.addWidget(expert_button) # passphrase passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT) passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN) passphrase_warning.setStyleSheet("color: red") cb_phrase = QCheckBox(_('Enable passphrases')) cb_phrase.setChecked(False) expert_vbox.addWidget(passphrase_msg) expert_vbox.addWidget(passphrase_warning) expert_vbox.addWidget(cb_phrase) # ask for recovery type (random word order OR matrix) bg_rectype = None if method == TIM_RECOVER and model == '1': gb_rectype = QGroupBox() hbox_rectype = QHBoxLayout() gb_rectype.setLayout(hbox_rectype) expert_vbox.addWidget(gb_rectype) gb_rectype.setTitle(_("Select recovery type:")) bg_rectype = QButtonGroup() rb1 = QRadioButton(gb_rectype) rb1.setText(_('Scrambled words')) bg_rectype.addButton(rb1) bg_rectype.setId(rb1, RecoveryDeviceType.ScrambledWords) hbox_rectype.addWidget(rb1) rb1.setChecked(True) rb2 = QRadioButton(gb_rectype) rb2.setText(_('Matrix')) bg_rectype.addButton(rb2) bg_rectype.setId(rb2, RecoveryDeviceType.Matrix) hbox_rectype.addWidget(rb2) # no backup cb_no_backup = None if method == TIM_NEW: cb_no_backup = QCheckBox(f'''{_('Enable seedless mode')}''') cb_no_backup.setChecked(False) if (model == '1' and fw_version >= (1, 7, 1) or model == 'T' and fw_version >= (2, 0, 9)): cb_no_backup.setToolTip(SEEDLESS_MODE_WARNING) else: cb_no_backup.setEnabled(False) cb_no_backup.setToolTip(_('Firmware version too old.')) expert_vbox.addWidget(cb_no_backup) vbox.addWidget(expert_widget) wizard.exec_layout(vbox, next_enabled=next_enabled) return TrezorInitSettings( word_count=bg_numwords.checkedId(), label=name.text(), pin_enabled=cb_pin.isChecked(), passphrase_enabled=cb_phrase.isChecked(), recovery_type=bg_rectype.checkedId() if bg_rectype else None, backup_type=bg_backuptype.checkedId(), no_backup=cb_no_backup.isChecked() if cb_no_backup else False, )
def __init__(self, df: pandas.DataFrame): """ :param df: low level dataframe of decided trace or most frequent routine """ # flags = Qt.Window | Qt.WindowTitleHint | Qt.CustomizeWindowHint super(ChoicesDialog, self).__init__() self.setWindowTitle("Choices") # self.setMaximumWidth(1000) # self.setMaximumHeight(600) if WINDOWS: self.setFixedWidth(1000) else: self.setFixedWidth(750) self.df = df # remove empty clipboard items for row_index, row in self.df.iterrows(): e = row['concept:name'] if (e in ['cut', 'copy', 'paste']) and utils.removeWhitespaces(row['clipboard_content']) == '': self.df = self.df.drop(row_index) # take selected event names mask1 = self.df['concept:name'].isin( ['changeField', 'editCell', 'editCellSheet', 'editRange', 'created', 'moved', 'Unmount', 'hotkey', 'copy'] ) # exclude paste in browser, take only paste in OS, do not consider cut or copy mask2 = ((self.df['concept:name'] == 'paste') & (self.df['category'] != 'Browser')) self.filtered_df = self.df[mask1 | mask2] if not self.filtered_df.empty: buttonBox = QDialogButtonBox(QDialogButtonBox.Ok) buttonBox.accepted.connect(self.handleReturn) if darkdetect.isDark(): buttonBox.setStyleSheet('QPushButton {background-color: #656565;}') formGroupBox = QGroupBox() self.layout = QFormLayout() self.addRows() formGroupBox.setLayout(self.layout) scroll = QScrollArea() scroll.setWidget(formGroupBox) scroll.setMaximumHeight(600) scroll.setMaximumWidth(1000) mainLayout = QVBoxLayout() mainLayout.addWidget(QLabel("Change input variables before generating RPA script")) mainLayout.addWidget(scroll) mainLayout.addWidget(buttonBox) self.setLayout(mainLayout) else: buttonBox = QDialogButtonBox(QDialogButtonBox.Ok) buttonBox.accepted.connect(self.accept) layout = QVBoxLayout(self) layout.addWidget(QLabel("Most frequent trace does not contain editable fields.\n" "Press OK to generate RPA script.")) layout.addWidget(buttonBox) self.setLayout(layout)
class WidgetGallery(QDialog): def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) styleLabel = QLabel("&Style:") styleLabel.setBuddy(styleComboBox) self.useStylePaletteCheckBox = QCheckBox( "&Use style's standard palette") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Disable widgets") self.createTopLeftGroupBox() self.createTopRightGroupBox() self.createBottomLeftTabWidget() self.createBottomRightGroupBox() self.createProgressBar() styleComboBox.activated[str].connect(self.changeStyle) self.useStylePaletteCheckBox.toggled.connect(self.changePalette) disableWidgetsCheckBox.toggled.connect( self.topLeftGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.topRightGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomLeftTabWidget.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomRightGroupBox.setDisabled) topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addWidget(styleComboBox) topLayout.addStretch(1) topLayout.addWidget(self.useStylePaletteCheckBox) topLayout.addWidget(disableWidgetsCheckBox) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.bottomLeftTabWidget, 2, 0) mainLayout.addWidget(self.bottomRightGroupBox, 2, 1) mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("Styles") self.changeStyle('Windows') def changeStyle(self, styleName): QApplication.setStyle(QStyleFactory.create(styleName)) self.changePalette() def changePalette(self): if (self.useStylePaletteCheckBox.isChecked()): QApplication.setPalette(QApplication.style().standardPalette()) else: QApplication.setPalette(self.originalPalette) def advanceProgressBar(self): curVal = self.progressBar.value() maxVal = self.progressBar.maximum() self.progressBar.setValue(curVal + (maxVal - curVal) / 100) def createTopLeftGroupBox(self): self.topLeftGroupBox = QGroupBox("Group 1") radioButton1 = QRadioButton("Radio button 1") radioButton2 = QRadioButton("Radio button 2") radioButton3 = QRadioButton("Radio button 3") radioButton1.setChecked(True) checkBox = QCheckBox("Tri-state check box") checkBox.setTristate(True) checkBox.setCheckState(Qt.PartiallyChecked) layout = QVBoxLayout() layout.addWidget(radioButton1) layout.addWidget(radioButton2) layout.addWidget(radioButton3) layout.addWidget(checkBox) layout.addStretch(1) self.topLeftGroupBox.setLayout(layout) def createTopRightGroupBox(self): self.topRightGroupBox = QGroupBox("Group 2") defaultPushButton = QPushButton("Default Push Button") defaultPushButton.setDefault(True) togglePushButton = QPushButton("Toggle Push Button") togglePushButton.setCheckable(True) togglePushButton.setChecked(True) flatPushButton = QPushButton("Flat Push Button") flatPushButton.setFlat(True) layout = QVBoxLayout() layout.addWidget(defaultPushButton) layout.addWidget(togglePushButton) layout.addWidget(flatPushButton) layout.addStretch(1) self.topRightGroupBox.setLayout(layout) def createBottomLeftTabWidget(self): self.bottomLeftTabWidget = QTabWidget() self.bottomLeftTabWidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Ignored) tab1 = QWidget() tableWidget = QTableWidget(10, 10) tab1hbox = QHBoxLayout() tab1hbox.setContentsMargins(5, 5, 5, 5) tab1hbox.addWidget(tableWidget) tab1.setLayout(tab1hbox) tab2 = QWidget() textEdit = QTextEdit() textEdit.setPlainText("Twinkle, twinkle, little star,\n" "How I wonder what you are.\n" "Up above the world so high,\n" "Like a diamond in the sky.\n" "Twinkle, twinkle, little star,\n" "How I wonder what you are!\n") tab2hbox = QHBoxLayout() tab2hbox.setContentsMargins(5, 5, 5, 5) tab2hbox.addWidget(textEdit) tab2.setLayout(tab2hbox) self.bottomLeftTabWidget.addTab(tab1, "&Table") self.bottomLeftTabWidget.addTab(tab2, "Text &Edit") def createBottomRightGroupBox(self): self.bottomRightGroupBox = QGroupBox("Group 3") self.bottomRightGroupBox.setCheckable(True) self.bottomRightGroupBox.setChecked(True) lineEdit = QLineEdit('s3cRe7') lineEdit.setEchoMode(QLineEdit.Password) spinBox = QSpinBox(self.bottomRightGroupBox) spinBox.setValue(50) dateTimeEdit = QDateTimeEdit(self.bottomRightGroupBox) dateTimeEdit.setDateTime(QDateTime.currentDateTime()) slider = QSlider(Qt.Horizontal, self.bottomRightGroupBox) slider.setValue(40) scrollBar = QScrollBar(Qt.Horizontal, self.bottomRightGroupBox) scrollBar.setValue(60) dial = QDial(self.bottomRightGroupBox) dial.setValue(30) dial.setNotchesVisible(True) layout = QGridLayout() layout.addWidget(lineEdit, 0, 0, 1, 2) layout.addWidget(spinBox, 1, 0, 1, 2) layout.addWidget(dateTimeEdit, 2, 0, 1, 2) layout.addWidget(slider, 3, 0) layout.addWidget(scrollBar, 4, 0) layout.addWidget(dial, 3, 1, 2, 1) layout.setRowStretch(5, 1) self.bottomRightGroupBox.setLayout(layout) def createProgressBar(self): self.progressBar = QProgressBar() self.progressBar.setRange(0, 10000) self.progressBar.setValue(0) timer = QTimer(self) timer.timeout.connect(self.advanceProgressBar) timer.start(1000)
def _make_edit_widgets(self, value_type, label, value): widgets = [] if value_type == ES2ValueType.bool: widget = QCheckBox() widget.setChecked(value) widget.setText(label) widgets.append(widget) elif value_type == ES2ValueType.float: widget = QLineEdit() widget.setText('{}'.format(value)) widgets.append(widget) elif value_type == ES2ValueType.int: widget = QLineEdit() widget.setText('{}'.format(value)) widgets.append(widget) elif value_type == ES2ValueType.string: widget = QLineEdit() widget.setText(value) widgets.append(widget) elif value_type == ES2ValueType.transform: groupbox = QGroupBox('Position') layout = QVBoxLayout() groupbox.setLayout(layout) for val in value.position.list(): field = QLineEdit() field.setText(str(val)) layout.addWidget(field) widgets.append(groupbox) groupbox = QGroupBox('Rotation') layout = QVBoxLayout() groupbox.setLayout(layout) for val in value.rotation.list(): field = QLineEdit() field.setText(str(val)) layout.addWidget(field) widgets.append(groupbox) groupbox = QGroupBox('Scale') layout = QVBoxLayout() groupbox.setLayout(layout) for val in value.scale.list(): field = QLineEdit() field.setText(str(val)) layout.addWidget(field) widgets.append(groupbox) groupbox = QGroupBox('Layer') layout = QVBoxLayout() groupbox.setLayout(layout) field = QLineEdit() field.setText(value.layer) layout.addWidget(field) widgets.append(groupbox) elif value_type == ES2ValueType.color: # groupbox = QGroupBox('Color') # layout = QVBoxLayout() # groupbox.setLayout(layout) for component in ('r', 'g', 'b', 'a'): val = getattr(value, component) field = QLineEdit() field.setText(str(val)) widgets.append(field) # layout.addWidget(field) # widgets.append(groupbox) return widgets
def runInputDialog(self, title, c1Text, c2Text, opText, outText, cell1, cell2, outCell): rows = [] cols = [] for r in range(self.table.rowCount()): rows.append(str(r + 1)) for c in range(self.table.columnCount()): cols.append(chr(ord('A') + c)) addDialog = QDialog(self) addDialog.setWindowTitle(title) group = QGroupBox(title, addDialog) group.setMinimumSize(250, 100) cell1Label = QLabel(c1Text, group) cell1RowInput = QComboBox(group) c1Row, c1Col = decode_pos(cell1) cell1RowInput.addItems(rows) cell1RowInput.setCurrentIndex(c1Row) cell1ColInput = QComboBox(group) cell1ColInput.addItems(cols) cell1ColInput.setCurrentIndex(c1Col) operatorLabel = QLabel(opText, group) operatorLabel.setAlignment(Qt.AlignHCenter) cell2Label = QLabel(c2Text, group) cell2RowInput = QComboBox(group) c2Row, c2Col = decode_pos(cell2) cell2RowInput.addItems(rows) cell2RowInput.setCurrentIndex(c2Row) cell2ColInput = QComboBox(group) cell2ColInput.addItems(cols) cell2ColInput.setCurrentIndex(c2Col) equalsLabel = QLabel("=", group) equalsLabel.setAlignment(Qt.AlignHCenter) outLabel = QLabel(outText, group) outRowInput = QComboBox(group) outRow, outCol = decode_pos(outCell) outRowInput.addItems(rows) outRowInput.setCurrentIndex(outRow) outColInput = QComboBox(group) outColInput.addItems(cols) outColInput.setCurrentIndex(outCol) cancelButton = QPushButton("Cancel", addDialog) cancelButton.clicked.connect(addDialog.reject) okButton = QPushButton("OK", addDialog) okButton.setDefault(True) okButton.clicked.connect(addDialog.accept) buttonsLayout = QHBoxLayout() buttonsLayout.addStretch(1) buttonsLayout.addWidget(okButton) buttonsLayout.addSpacing(10) buttonsLayout.addWidget(cancelButton) dialogLayout = QVBoxLayout(addDialog) dialogLayout.addWidget(group) dialogLayout.addStretch(1) dialogLayout.addItem(buttonsLayout) cell1Layout = QHBoxLayout() cell1Layout.addWidget(cell1Label) cell1Layout.addSpacing(10) cell1Layout.addWidget(cell1ColInput) cell1Layout.addSpacing(10) cell1Layout.addWidget(cell1RowInput) cell2Layout = QHBoxLayout() cell2Layout.addWidget(cell2Label) cell2Layout.addSpacing(10) cell2Layout.addWidget(cell2ColInput) cell2Layout.addSpacing(10) cell2Layout.addWidget(cell2RowInput) outLayout = QHBoxLayout() outLayout.addWidget(outLabel) outLayout.addSpacing(10) outLayout.addWidget(outColInput) outLayout.addSpacing(10) outLayout.addWidget(outRowInput) vLayout = QVBoxLayout(group) vLayout.addItem(cell1Layout) vLayout.addWidget(operatorLabel) vLayout.addItem(cell2Layout) vLayout.addWidget(equalsLabel) vLayout.addStretch(1) vLayout.addItem(outLayout) if addDialog.exec_(): cell1 = cell1ColInput.currentText() + cell1RowInput.currentText() cell2 = cell2ColInput.currentText() + cell2RowInput.currentText() outCell = outColInput.currentText() + outRowInput.currentText() return True, cell1, cell2, outCell return False, None, None, None
class Navigation(QtCore.QObject): clicked = QtCore.pyqtSignal(QtCore.QModelIndex) def __init__(self, json_data, parent=None): super(Navigation, self).__init__(parent) self.toolbar = QtWidgets.QToolBar() self.toolbar.actionTriggered.connect(self.on_actionTriggered) self.model = QtGui.QStandardItemModel(self) dict_to_model(self.model.invisibleRootItem(), json_data) it = self.model.item(0, 0) ix = self.model.indexFromItem(it) root_action = self.toolbar.addAction(it.text()) root_action.setData(QtCore.QPersistentModelIndex(ix)) self.listview = QtWidgets.QListView() self.listview.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.listview.clicked.connect(self.on_clicked) self.listview.setModel(self.model) self.listview.setRootIndex(ix) self.a = 10 self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.gridLayout.addWidget(self.listview, 0, 0, 2, 1) self.frame = QtWidgets.QFrame() self.chart = Chart('Alloys', self) self.ly = QtWidgets.QVBoxLayout() self.frame.setLayout(self.ly) #self.layout.addWidget(self.frame) #self.frame.hide() self.gridLayout1 = QtWidgets.QGridLayout() self.gridLayout1.addWidget(self.frame) self.gridLayout2 = QtWidgets.QGridLayout() self.gridLayout2.addWidget(self.chart.chartview) self.gridLayout.addLayout(self.gridLayout2, 0, 2, 0, 1) self.gridLayout.addLayout(self.gridLayout1, 0, 2, 0, 1) '''self.layout = QHBoxLayout() self.frame = QtWidgets.QFrame() self.layout.addWidget(self.listview) self.chart = Chart('Alloys', self.frame) self.layout.addWidget(self.chart.chartview) ly = QtWidgets.QVBoxLayout() self.frame.setLayout(ly) ly.addWidget(self.chart.table) self.layout.addWidget(self.frame) #self.frame.hide()''' self.horizontalGroupBox = QGroupBox() self.horizontalGroupBox.setLayout(self.gridLayout) #make the listed items clickable @QtCore.pyqtSlot(QtCore.QModelIndex) def on_clicked(self, index): print('aaaaaaaaaaaaaa', self.a) if not self.model.hasChildren(index): self.clicked.emit(index) return action = self.toolbar.addAction(index.data()) action.setData(QtCore.QPersistentModelIndex(index)) self.listview.setRootIndex(index) print(index.data()) self.chart.addSeries(index.data()) #make the breadcrumbs clickable in order to go back and forth @QtCore.pyqtSlot(QtWidgets.QAction) def on_actionTriggered(self, action): ix = action.data() self.chart.addSeries(ix.data()) model = ix.model() self.listview.setRootIndex(QtCore.QModelIndex(ix)) self.toolbar.clear() ixs = [] while ix.isValid(): ixs.append(ix) ix = ix.parent() for ix in reversed(ixs): action = self.toolbar.addAction(ix.data()) action.setData(ix)
def __init__(self, json_data, parent=None): super(Navigation, self).__init__(parent) self.toolbar = QtWidgets.QToolBar() self.toolbar.actionTriggered.connect(self.on_actionTriggered) self.model = QtGui.QStandardItemModel(self) dict_to_model(self.model.invisibleRootItem(), json_data) it = self.model.item(0, 0) ix = self.model.indexFromItem(it) root_action = self.toolbar.addAction(it.text()) root_action.setData(QtCore.QPersistentModelIndex(ix)) self.listview = QtWidgets.QListView() self.listview.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.listview.clicked.connect(self.on_clicked) self.listview.setModel(self.model) self.listview.setRootIndex(ix) self.a = 10 self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.gridLayout.addWidget(self.listview, 0, 0, 2, 1) self.frame = QtWidgets.QFrame() self.chart = Chart('Alloys', self) self.ly = QtWidgets.QVBoxLayout() self.frame.setLayout(self.ly) #self.layout.addWidget(self.frame) #self.frame.hide() self.gridLayout1 = QtWidgets.QGridLayout() self.gridLayout1.addWidget(self.frame) self.gridLayout2 = QtWidgets.QGridLayout() self.gridLayout2.addWidget(self.chart.chartview) self.gridLayout.addLayout(self.gridLayout2, 0, 2, 0, 1) self.gridLayout.addLayout(self.gridLayout1, 0, 2, 0, 1) '''self.layout = QHBoxLayout() self.frame = QtWidgets.QFrame() self.layout.addWidget(self.listview) self.chart = Chart('Alloys', self.frame) self.layout.addWidget(self.chart.chartview) ly = QtWidgets.QVBoxLayout() self.frame.setLayout(ly) ly.addWidget(self.chart.table) self.layout.addWidget(self.frame) #self.frame.hide()''' self.horizontalGroupBox = QGroupBox() self.horizontalGroupBox.setLayout(self.gridLayout)
class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.gridGroupBox = QGroupBox("參數設定", self) layout = QGridLayout() self.manLabel = QLabel("測試人員", self) self.manLabel.resize(50, 250) self.combo001 = QComboBox(self) self.combo001.addItem('男性') self.combo001.addItem('女性') self.combo001.resize(50, 400) self.hightLabel = QLabel("身高(cm)", self) self.combo002 = QComboBox(self) self.combo002.addItem('150') self.combo002.addItem('160') self.combo002.addItem('170') self.combo002.addItem('180') self.combo002.addItem('190') self.strainLabel = QLabel("拉伸應變(%)", self) self.combo003 = QComboBox(self) self.combo003.addItem('5%') self.combo003.addItem('7.5%') self.combo003.addItem('10%') self.combo003.addItem('12.5%') self.combo003.addItem('15%') # self.combo003.activated[str].connect(self.onActivated) layout.setSpacing(20) layout.addWidget(self.manLabel, 1, 0) layout.addWidget(self.combo001, 1, 1) layout.addWidget(self.hightLabel, 2, 0) layout.addWidget(self.combo002, 2, 1) layout.addWidget(self.strainLabel, 3, 0) # layout.addWidget(self.emitLineEdit,2,1) layout.addWidget(self.combo003, 3, 1) self.noLabel1 = QLabel("案例編號", self) self.noLineEdit1 = QLineEdit("POC-", self) self.caseLabel1 = QLabel("案例名稱", self) self.caseLineEdit1 = QLineEdit(" ", self) self.dateLabel1 = QLabel("更新日期", self) self.dateLineEdit1 = QLineEdit("2021-01-", self) layout.setSpacing(20) layout.addWidget(self.noLabel1, 4, 0) layout.addWidget(self.noLineEdit1, 4, 1) layout.addWidget(self.caseLabel1, 5, 0) layout.addWidget(self.caseLineEdit1, 5, 1) layout.addWidget(self.dateLabel1, 6, 0) layout.addWidget(self.dateLineEdit1, 6, 1) self.pushButton_A01 = QPushButton() ### self.pushButton_A01.setGeometry(QtCore.QRect(10, 30, 45, 35)) self.pushButton_A01.setObjectName("pushButton_014") self.pushButton_A01.setStyleSheet( "background-color: #1F1F1F; color: white;font: 100 10pt \"Arial Narrow\"" ) self.pushButton_A01.setText("存檔") # self.pushButton_014.setFont(QFont('Arial', 5)) # self.pushButton_A01.scaled(20,15, Qt.KeepAspectRatio, Qt.SmoothTransformation) self.pushButton_A01.setStyleSheet( "QPushButton{color:white}" "QPushButton:hover{color:yellow}" ## "QPushButton{border-image: url(/FHEUI/fig/max1.png)}" # "QPushButton{background-image: url(/FHEUI/fig/max1.png)}" "QPushButton{background-color:#1E1E1E}" # "QPushButton:hover{background-image:url(/FHEUI/fig/max2.png)}" "QPushButton{border:1px}" "QPushButton{border-radius:2px}" "QPushButton{font: 10pt} " "QPushButton{padding:2px 4px}") self.pushButton_A01.clicked.connect(self.saveas001) self.pushButton_A02 = QPushButton() ### self.pushButton_A01.setGeometry(QtCore.QRect(10, 30, 45, 35)) self.pushButton_A02.setObjectName("pushButton_014") self.pushButton_A02.setStyleSheet( "background-color: #1F1F1F; color: white;font: 100 10pt \"Arial Narrow\"" ) self.pushButton_A02.setText("修改") # self.pushButton_014.setFont(QFont('Arial', 5)) # self.pushButton_A01.scaled(20,15, Qt.KeepAspectRatio, Qt.SmoothTransformation) self.pushButton_A02.setStyleSheet( "QPushButton{color:white}" "QPushButton:hover{color:yellow}" ## "QPushButton{border-image: url(/FHEUI/fig/max1.png)}" # "QPushButton{background-image: url(/FHEUI/fig/max1.png)}" "QPushButton{background-color:#1E1E1E}" # "QPushButton:hover{background-image:url(/FHEUI/fig/max2.png)}" "QPushButton{border:1px}" "QPushButton{border-radius:2px}" "QPushButton{font: 10pt} " "QPushButton{padding:2px 4px}") self.pushButton_A02.clicked.connect(self.modify001) layout.addWidget(self.pushButton_A01, 7, 0) layout.addWidget(self.pushButton_A02, 7, 1) layout.setColumnStretch(1, 1) self.gridGroupBox.setLayout(layout) self.gridGroupBox.resize(400, 450) self.setWindowTitle('智慧褲線路佈局') self.setWindowIcon(QIcon('fig\itrilogo.png')) self.setGeometry(475, 200, 400, 450) self.show() def modify001(self): self.noLineEdit1.clear() self.caseLineEdit1.setText(" ") self.dateLineEdit1.setText(" ") def saveas001(self, text): text001 = str(self.noLineEdit1.text()) text002 = str(self.caseLineEdit1.text()) text003 = str(self.dateLineEdit1.text()) text004 = "FHE ID_001" text005 = str(self.combo001.currentText()) text006 = str(self.combo002.currentText()) text007 = str(self.combo003.currentText()) # print(text001) filename, filetype = QFileDialog.getSaveFileName( self, "Save File", "*.txt") with open(filename, 'w', encoding='utf-8-sig') as f: print(filename) f.write(text001 + '\n') f.write(text002 + '\n') f.write(text003 + '\n') f.write(text004 + '\n') f.write(text005 + '\n') f.write(text006 + '\n') f.write(text007) f.close()
def initUI(self): self.gridGroupBox = QGroupBox("參數設定", self) layout = QGridLayout() self.manLabel = QLabel("測試人員", self) self.manLabel.resize(50, 250) self.combo001 = QComboBox(self) self.combo001.addItem('男性') self.combo001.addItem('女性') self.combo001.resize(50, 400) self.hightLabel = QLabel("身高(cm)", self) self.combo002 = QComboBox(self) self.combo002.addItem('150') self.combo002.addItem('160') self.combo002.addItem('170') self.combo002.addItem('180') self.combo002.addItem('190') self.strainLabel = QLabel("拉伸應變(%)", self) self.combo003 = QComboBox(self) self.combo003.addItem('5%') self.combo003.addItem('7.5%') self.combo003.addItem('10%') self.combo003.addItem('12.5%') self.combo003.addItem('15%') # self.combo003.activated[str].connect(self.onActivated) layout.setSpacing(20) layout.addWidget(self.manLabel, 1, 0) layout.addWidget(self.combo001, 1, 1) layout.addWidget(self.hightLabel, 2, 0) layout.addWidget(self.combo002, 2, 1) layout.addWidget(self.strainLabel, 3, 0) # layout.addWidget(self.emitLineEdit,2,1) layout.addWidget(self.combo003, 3, 1) self.noLabel1 = QLabel("案例編號", self) self.noLineEdit1 = QLineEdit("POC-", self) self.caseLabel1 = QLabel("案例名稱", self) self.caseLineEdit1 = QLineEdit(" ", self) self.dateLabel1 = QLabel("更新日期", self) self.dateLineEdit1 = QLineEdit("2021-01-", self) layout.setSpacing(20) layout.addWidget(self.noLabel1, 4, 0) layout.addWidget(self.noLineEdit1, 4, 1) layout.addWidget(self.caseLabel1, 5, 0) layout.addWidget(self.caseLineEdit1, 5, 1) layout.addWidget(self.dateLabel1, 6, 0) layout.addWidget(self.dateLineEdit1, 6, 1) self.pushButton_A01 = QPushButton() ### self.pushButton_A01.setGeometry(QtCore.QRect(10, 30, 45, 35)) self.pushButton_A01.setObjectName("pushButton_014") self.pushButton_A01.setStyleSheet( "background-color: #1F1F1F; color: white;font: 100 10pt \"Arial Narrow\"" ) self.pushButton_A01.setText("存檔") # self.pushButton_014.setFont(QFont('Arial', 5)) # self.pushButton_A01.scaled(20,15, Qt.KeepAspectRatio, Qt.SmoothTransformation) self.pushButton_A01.setStyleSheet( "QPushButton{color:white}" "QPushButton:hover{color:yellow}" ## "QPushButton{border-image: url(/FHEUI/fig/max1.png)}" # "QPushButton{background-image: url(/FHEUI/fig/max1.png)}" "QPushButton{background-color:#1E1E1E}" # "QPushButton:hover{background-image:url(/FHEUI/fig/max2.png)}" "QPushButton{border:1px}" "QPushButton{border-radius:2px}" "QPushButton{font: 10pt} " "QPushButton{padding:2px 4px}") self.pushButton_A01.clicked.connect(self.saveas001) self.pushButton_A02 = QPushButton() ### self.pushButton_A01.setGeometry(QtCore.QRect(10, 30, 45, 35)) self.pushButton_A02.setObjectName("pushButton_014") self.pushButton_A02.setStyleSheet( "background-color: #1F1F1F; color: white;font: 100 10pt \"Arial Narrow\"" ) self.pushButton_A02.setText("修改") # self.pushButton_014.setFont(QFont('Arial', 5)) # self.pushButton_A01.scaled(20,15, Qt.KeepAspectRatio, Qt.SmoothTransformation) self.pushButton_A02.setStyleSheet( "QPushButton{color:white}" "QPushButton:hover{color:yellow}" ## "QPushButton{border-image: url(/FHEUI/fig/max1.png)}" # "QPushButton{background-image: url(/FHEUI/fig/max1.png)}" "QPushButton{background-color:#1E1E1E}" # "QPushButton:hover{background-image:url(/FHEUI/fig/max2.png)}" "QPushButton{border:1px}" "QPushButton{border-radius:2px}" "QPushButton{font: 10pt} " "QPushButton{padding:2px 4px}") self.pushButton_A02.clicked.connect(self.modify001) layout.addWidget(self.pushButton_A01, 7, 0) layout.addWidget(self.pushButton_A02, 7, 1) layout.setColumnStretch(1, 1) self.gridGroupBox.setLayout(layout) self.gridGroupBox.resize(400, 450) self.setWindowTitle('智慧褲線路佈局') self.setWindowIcon(QIcon('fig\itrilogo.png')) self.setGeometry(475, 200, 400, 450) self.show()
class KNN(QMainWindow): send_fig = pyqtSignal(str) # To manage the signals PyQT manages the communication def __init__(self): #::-------------------------------------------------------- # Initialize the values of the class # Here the class inherits all the attributes and methods from the QMainWindow #::-------------------------------------------------------- super(KNN, self).__init__() self.Title = 'Title : K-Nearest Neighbor ' self.initUi() def initUi(self): #::-------------------------------------------------------------- # We create the type of layout QVBoxLayout (Vertical Layout ) # This type of layout comes from QWidget #::-------------------------------------------------------------- self.v = "24 Categories" self.setWindowTitle(self.Title) self.main_widget = QWidget(self) self.layout = QVBoxLayout(self.main_widget) # Creates vertical layout self.groupBox1 = QGroupBox('Number of Categories') self.groupBox1Layout = QHBoxLayout() self.groupBox1.setLayout(self.groupBox1Layout) self.groupBox2 = QGroupBox('Accuracy and MSE') self.groupBox2Layout = QGridLayout() self.groupBox2.setLayout(self.groupBox2Layout) self.label1 = QLabel("Accuracy: 22.18") self.label2 = QLabel("MSE: 5.84") self.label3 = QLabel("Accuracy: 95.32") #self.label4 = QLabel("MSE: 0.05") self.groupBox2Layout.addWidget(self.label1, 0, 0) self.groupBox2Layout.addWidget(self.label2, 1, 0) self.groupBox2Layout.addWidget(self.label3, 0, 1) #self.groupBox2Layout.addWidget(self.label4, 1, 1) self.groupBox3 = QGroupBox('Graphic') self.groupBox3Layout = QVBoxLayout() self.groupBox3.setLayout(self.groupBox3Layout) # Radio buttons are create to be added to the second group self.b1 = QRadioButton("24 Categories") self.b1.setChecked(True) self.b1.toggled.connect(self.onClicked) self.b2 = QRadioButton("3 Categories") self.b2.toggled.connect(self.onClicked) self.buttonlabel = QLabel(self.v+' is selected') self.groupBox1Layout.addWidget(self.b1) self.groupBox1Layout.addWidget(self.b2) self.groupBox1Layout.addWidget(self.buttonlabel) # figure and canvas figure to draw the graph is created to self.fig = Figure() self.ax1 = self.fig.add_subplot(111) self.canvas = FigureCanvas(self.fig) self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.canvas.updateGeometry() # Canvas is added to the third group box self.groupBox3Layout.addWidget(self.canvas) # Adding to the main layout the groupboxes self.layout.addWidget(self.groupBox1) self.layout.addWidget(self.groupBox2) self.layout.addWidget(self.groupBox3) self.setCentralWidget(self.main_widget) # Creates the window with all the elements self.resize(600, 500) # Resize the window self.onClicked() def onClicked(self): # Figure is cleared to create the new graph with the choosen parameters self.ax1.clear() # the buttons are inspect to indicate which one is checked. # vcolor is assigned the chosen color if self.b1.isChecked(): self.v = self.b1.text() df_cm = pd.read_csv('KNN_cm.csv') im = self.ax1.imshow(df_cm) # We want to show all ticks... self.ax1.set_xticks(np.arange(1, df_cm.shape[0] + 1)) self.ax1.set_yticks(np.arange(df_cm.shape[0])) # ... and label them with the respective list entries self.ax1.set_xticklabels(np.arange(-12, 12)) self.ax1.set_yticklabels(np.arange(-12, 12)) # Rotate the tick labels and set their alignment. plt.setp(self.ax1.get_xticklabels(), rotation=45, ha="right", rotation_mode="anchor") # Loop over data dimensions and create text annotations. for i in range(df_cm.shape[0]): for j in range(1, df_cm.shape[0] + 1): text = self.ax1.text(j, i, df_cm.iloc[i, j], ha="center", va="center", color="w", fontsize=6) vtitle = "Confusion Matrix" self.ax1.set_title(vtitle) self.ax1.set_xlabel('Predicted label', fontsize=10) self.ax1.set_ylabel('True label', fontsize=10) if self.b2.isChecked(): self.v = self.b2.text() df_cm = pd.read_csv('KNN_cm_improve2.csv') im = heatmap(df_cm.iloc[:, 1:df_cm.shape[0] + 1], ['[-12, -4)', '[-4, 4)', '[4, 12)'], ['[-12, -4)', '[-4, 4)', '[4, 12)'], ax=self.ax1) texts = annotate_heatmap(im, valfmt="{x:.1f}") # the label that displays the selected option self.buttonlabel.setText(self.v + ' is selected') # show the plot self.fig.tight_layout() self.fig.canvas.draw_idle()
def create4Groupbox(self): bx = QGroupBox('4th group') return bx
def display_parameters(self, node_name, process, pipeline): """ Displays the parameters of the selected node The node parameters are read and line labels/line edits/push buttons are created for each of them. This methods consists mainly in widget and layout organization. :param node_name: name of the node :param process: process of the node :param pipeline: current pipeline :return: """ self.node_name = node_name self.line_edit_input = [] self.line_edit_output = [] self.labels_input = [] self.labels_output = [] if len(self.children()) > 0: self.clearLayout(self) self.v_box_final = QVBoxLayout() # Node name label_node_name = QLabel() label_node_name.setText('Node name:') self.line_edit_node_name = QLineEdit() # The pipeline global inputs and outputs node name cannot be modified if self.node_name not in ('inputs', 'outputs'): self.line_edit_node_name.setText(self.node_name) self.line_edit_node_name.returnPressed.connect( partial(self.update_node_name, pipeline)) else: self.line_edit_node_name.setText('Pipeline inputs/outputs') self.line_edit_node_name.setReadOnly(True) self.h_box_node_name = QHBoxLayout() self.h_box_node_name.addWidget(label_node_name) self.h_box_node_name.addWidget(self.line_edit_node_name) # Inputs self.button_group_inputs = QGroupBox('Inputs') self.v_box_inputs = QVBoxLayout() idx = 0 for name, trait in process.user_traits().items(): if name == 'nodes_activation': continue if not trait.output: label_input = QLabel() label_input.setText(str(name)) self.labels_input.insert(idx, label_input) try: value = getattr(process, name) except TraitError: value = Undefined trait_type = trait_ids(process.trait(name)) self.line_edit_input.insert(idx, QLineEdit()) self.line_edit_input[idx].setText(str(value)) self.line_edit_input[idx].returnPressed.connect( partial(self.update_plug_value, 'in', name, pipeline, type(value))) h_box = QHBoxLayout() h_box.addWidget(label_input) h_box.addWidget(self.line_edit_input[idx]) # Adding the possibility to filter pipeline global inputs except if the input is "database_scans" # which means that the scans will be filtered with InputFilter if self.node_name == "inputs" and name != "database_scans": parameters = (idx, pipeline, type(value)) push_button = QPushButton('Filter') push_button.clicked.connect( partial(self.display_filter, self.node_name, name, parameters, process)) h_box.addWidget(push_button) self.v_box_inputs.addLayout(h_box) idx += 1 self.button_group_inputs.setLayout(self.v_box_inputs) # Outputs self.button_group_outputs = QGroupBox('Outputs') self.v_box_outputs = QVBoxLayout() idx = 0 for name, trait in process.traits(output=True).items(): label_output = QLabel() label_output.setText(str(name)) self.labels_output.insert(idx, label_output) value = getattr(process, name) trait_type = trait_ids(process.trait(name)) self.line_edit_output.insert(idx, QLineEdit()) self.line_edit_output[idx].setText(str(value)) self.line_edit_output[idx].returnPressed.connect( partial(self.update_plug_value, 'out', name, pipeline, type(value))) h_box = QHBoxLayout() h_box.addWidget(label_output) h_box.addWidget(self.line_edit_output[idx]) self.v_box_outputs.addLayout(h_box) idx += 1 self.button_group_outputs.setLayout(self.v_box_outputs) self.v_box_final.addLayout(self.h_box_node_name) self.v_box_final.addWidget(self.button_group_inputs) self.v_box_final.addWidget(self.button_group_outputs) self.setLayout(self.v_box_final)
class TestTool(QTabWidget): def __init__(self, parent=None): super(TestTool, self).__init__(parent) self.init_title() screenRect = QApplication.instance().desktop().availableGeometry() # get the screen width and height width = screenRect.width()*60/100 height = screenRect.height()*70/100 self.resize(width, height) self.parser_config() self.initUI() self.init_data() def init_title(self): title = 'MPTOOL4PC .IO Test Tools(2018-07-26)' self.setWindowTitle(title) def initUI(self): self.test_unit_1() self.test_unit_2() self.create_info_show() mainLayout = QVBoxLayout() mainLayout.addWidget(self.gridGroupBox) mainLayout.addWidget(self.gridGroup2) mainLayout.addWidget(self.QGroupBox_info_show) self.setLayout(mainLayout) def init_data(self): print("init_data") self.fts = fts_database() self.thread_running = False self.net = network() self.cmd_input.returnPressed.connect(self.handle_cmd) def test_unit_1(self): self.gridGroupBox = QGroupBox("模拟FTS") layout = QGridLayout() self.fts_info = QLabel("点击按钮启动自动更新测试数据到FTS数据库...") self.fts_info.setFont(QFont("Microsoft YaHei", 15)) layout.addWidget(self.fts_info, 0, 0) ButtonStart = QPushButton("Start") ButtonStart.setFont(QFont("Microsoft YaHei", 10)) ButtonStart.clicked.connect(self.start_thread_update_fts_data) layout.addWidget(ButtonStart, 0, 1) ButtonStop = QPushButton("Stop") ButtonStop.setFont(QFont("Microsoft YaHei", 10)) ButtonStop.clicked.connect(self.stop_thread_update_fts_data) layout.addWidget(ButtonStop, 0, 2) layout.setColumnStretch(0, 8) layout.setColumnStretch(1, 1) layout.setColumnStretch(2, 1) self.gridGroupBox.setLayout(layout) def test_unit_2(self): self.gridGroup2= QGroupBox("Test 2 上传mac到tn4cio") layout = QGridLayout() self.cmd_input = QLineEdit(self) self.cmd_input.setFont(QFont("Microsoft YaHei", 25)) self.cmd_input.setStyleSheet("color:black") self.cmd_input.installEventFilter(self) layout.addWidget(self.cmd_input, 0, 0) self.gridGroup2.setLayout(layout) def create_info_show(self): self.QGroupBox_info_show = QGroupBox("运行信息") layout = QGridLayout() print("info show for the process logs") self.info_show = QTextEdit() self.info_show.setPlainText("提示信息显示") self.info_show.setFont(QFont("Microsoft YaHei", 15)) cursor = self.info_show.textCursor() cursor.movePosition(QTextCursor.End) self.info_show.setTextCursor(cursor) layout.addWidget(self.info_show, 0, 0) self.QGroupBox_info_show.setLayout(layout) self.info_show.setReadOnly(True) # overwrite the window close function def closeEvent(self, event): print("event:", event) self.stop_thread_update_fts_data() def parser_config(self): config = 'config.ini' cur_dir = os.getcwd() config_path = os.path.join(cur_dir, config) if os.path.exists(config_path): conf = configparser.ConfigParser() conf.read(config_path) self.station = conf.get('Station', 'station') self.tn4cioip = conf.get('Corelight', 'tn4cioip') self.ml1_printer = conf.get('Printer', 'ml1_printer') self.pl2_printer = conf.get('Printer', 'pl2_printer') self.gcl_printer = conf.get('Printer', 'gcl_printer') else: pass def start_thread_update_fts_data(self): print("--------------start thread for auto update data to fts db-------------") if self.thread_running == False: self.thread_running = True t = threading.Thread(target=self.write_data) t.start() else: self.fts_info.setText("FTS 自动更新数据已经在运行中") print("thread already running") def stop_thread_update_fts_data(self): print("-----------------stop thread for update fts data-----------------") self.thread_running = False self.fts_info.setText("FTS 自动更新数据已经停止,点击启动开始") def write_data(self): while self.thread_running == True: ret = self.fts.wtite_fts_test_data() print(ret) text = json.loads(ret) fts_id = text['fts_id'] fts_mac = text['fts_mac'] self.update_fts_data_show(fts_id, fts_mac) sleep(10) def update_fts_data_show(self, id, mac): self.fts_info.setText("Auto add id: "+ id + " mac: "+ mac) def handle_cmd(self): mac = self.cmd_input.text() self.cmd_input.clear() ret = self.net.upload_mac_and_fts(mac, "pass") print(ret) tmp = json.loads(ret) msg_type = tmp['messages'][0]['type'] msg = tmp['messages'][0]['message'] if msg_type == "ok": self.info_show.setText("成功更新MAC: "+mac) else: if msg == "db is full!": self.info_show.setText("上传MAC:"+mac+" 失败,数据库已经无可用空间!") elif msg == "update mac to db fail!": self.info_show.setText("上传MAC:"+mac+" 失败!") elif msg == "already exist in the database": self.info_show.setText("MAC:"+mac+" 已经在数据库中!")
def initUi(self): #::-------------------------------------------------------------- # We create the type of layout QVBoxLayout (Vertical Layout ) # This type of layout comes from QWidget #::-------------------------------------------------------------- self.v = "24 Categories" self.setWindowTitle(self.Title) self.main_widget = QWidget(self) self.layout = QVBoxLayout(self.main_widget) # Creates vertical layout self.groupBox1 = QGroupBox('Number of Categories') self.groupBox1Layout = QHBoxLayout() self.groupBox1.setLayout(self.groupBox1Layout) self.groupBox2 = QGroupBox('Accuracy and MSE') self.groupBox2Layout = QGridLayout() self.groupBox2.setLayout(self.groupBox2Layout) self.label1 = QLabel("Accuracy: 22.18") self.label2 = QLabel("MSE: 5.84") self.label3 = QLabel("Accuracy: 95.32") #self.label4 = QLabel("MSE: 0.05") self.groupBox2Layout.addWidget(self.label1, 0, 0) self.groupBox2Layout.addWidget(self.label2, 1, 0) self.groupBox2Layout.addWidget(self.label3, 0, 1) #self.groupBox2Layout.addWidget(self.label4, 1, 1) self.groupBox3 = QGroupBox('Graphic') self.groupBox3Layout = QVBoxLayout() self.groupBox3.setLayout(self.groupBox3Layout) # Radio buttons are create to be added to the second group self.b1 = QRadioButton("24 Categories") self.b1.setChecked(True) self.b1.toggled.connect(self.onClicked) self.b2 = QRadioButton("3 Categories") self.b2.toggled.connect(self.onClicked) self.buttonlabel = QLabel(self.v+' is selected') self.groupBox1Layout.addWidget(self.b1) self.groupBox1Layout.addWidget(self.b2) self.groupBox1Layout.addWidget(self.buttonlabel) # figure and canvas figure to draw the graph is created to self.fig = Figure() self.ax1 = self.fig.add_subplot(111) self.canvas = FigureCanvas(self.fig) self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.canvas.updateGeometry() # Canvas is added to the third group box self.groupBox3Layout.addWidget(self.canvas) # Adding to the main layout the groupboxes self.layout.addWidget(self.groupBox1) self.layout.addWidget(self.groupBox2) self.layout.addWidget(self.groupBox3) self.setCentralWidget(self.main_widget) # Creates the window with all the elements self.resize(600, 500) # Resize the window self.onClicked()
def creatui(self): self.icon_title = QIcon() self.icon_title.addPixmap(QPixmap(":/img/title.ico"), QIcon.Normal, QIcon.Off) #标题图表 self.icon_save = QIcon() self.icon_save.addPixmap(QPixmap(":/img/save.ico"), QIcon.Normal, QIcon.Off) #保存图表 self.icon_help = QIcon() self.icon_help.addPixmap(QPixmap(":/img/help.ico"), QIcon.Normal, QIcon.Off) # 帮助图表 self.icon_aboat = QIcon() self.icon_aboat.addPixmap(QPixmap(":/img/about.ico"), QIcon.Normal, QIcon.Off) #关于图表 self.icon_github = QIcon() self.icon_github.addPixmap(QPixmap(":/img/github.ico"), QIcon.Normal, QIcon.Off) #关于图表 self.setWindowTitle('自定义报表程序') self.setGeometry(300, 300, 650, 270) #self.setFixedSize(self.width(), self.height()) self.permissionsGroup = QGroupBox("服务器信息") self.permissionsLayout = QGridLayout() self.setWindowIcon(self.icon_title) ######################################### self.qm = QMainWindow() exitAct = QAction(self.icon_save, "保存配置", self.qm) exitAct.setShortcut("Ctrl+S") exitAct.triggered.connect(self.saveconfig) self.toolbar = self.qm.addToolBar("save") exitAct1 = QAction(self.icon_help, "帮助", self.qm) exitAct1.setShortcut("Ctrl+H") exitAct1.triggered.connect(self.openhelp) exitAct2 = QAction(self.icon_aboat, "关于", self.qm) exitAct2.setShortcut("Ctrl+I") exitAct2.triggered.connect(self.openaboat) exitAct3 = QAction(self.icon_github, "查看源码", self.qm) exitAct3.setShortcut("Ctrl+M") exitAct3.triggered.connect(self.openaurl) self.toolbar.addAction(exitAct) self.toolbar.addAction(exitAct1) self.toolbar.addAction(exitAct2) self.toolbar.addAction(exitAct3) self.updatlabel = QLabel('', self.toolbar) self.updatlabel.setOpenExternalLinks(True) self.updatlabel.setFixedWidth(150) self.updatlabel.move(500, 0) ###############第一行############### self.permissionsLayout.addWidget(QLabel('数据库', self.permissionsGroup), 1, 0) self.le_host = QLineEdit('', self.permissionsGroup) #self.le_host.editingFinished.connect(self.initserver) self.le_host.setInputMask('000.000.000.000') self.le_host.insert(config['server']['host']) self.le_host.setFixedWidth(100) #print((self.le_host.height(),self.le_host.width())) self.permissionsLayout.addWidget(QLabel('端口', self.permissionsGroup), 1, 2) self.le_port = QLineEdit('', self.permissionsGroup) self.le_port.setInputMask('99999') self.le_port.insert(config['server']['port']) #self.le_port.editingFinished.connect(self.initserver) self.le_port.setFixedWidth(40) self.permissionsLayout.addWidget(QLabel('用户名', self.permissionsGroup), 1, 4) self.le_usr = QLineEdit('', self.permissionsGroup) self.le_usr.insert(config['server']['user']) #self.le_usr.editingFinished.connect(self.initserver) self.le_usr.setFixedWidth(40) self.permissionsLayout.addWidget(QLabel('密码', self.permissionsGroup), 1, 6) self.le_passwd = QLineEdit('', self.permissionsGroup) self.le_passwd.insert(config['server']['passwd']) #self.le_passwd.editingFinished.connect(self.initserver) self.le_passwd.setFixedWidth(100) self.le_passwd.setEchoMode(QLineEdit.PasswordEchoOnEdit) self.permissionsLayout.addWidget(QLabel('数据库名', self.permissionsGroup), 1, 8) self.le_db = QLineEdit('', self.permissionsGroup) self.le_db.insert(config['server']['db']) self.le_db.setFixedWidth(80) #self.le_db.editingFinished.connect(self.initserver) ################################## self.permissionsLayout.addWidget(QLabel('设备名', self.permissionsGroup), 2, 0) self.le_devname = QLineEdit('', self.permissionsGroup) self.permissionsLayout.addWidget(self.le_devname, 2, 1, 1, 8) self.le_devname.setFixedWidth(600) self.qtb1 = QPushButton('查询', self) self.permissionsLayout.addWidget(self.qtb1, 2, 9) self.qtb1.clicked.connect(self.work) ############################## self.permissionsLayout.addWidget(self.le_host, 1, 1) self.permissionsLayout.addWidget(self.le_port, 1, 3) self.permissionsLayout.addWidget(self.le_usr, 1, 5) self.permissionsLayout.addWidget(self.le_passwd, 1, 7) self.permissionsLayout.addWidget(self.le_db, 1, 9) self.permissionsGroup.setLayout(self.permissionsLayout) self.mainLayout = QVBoxLayout() self.mainLayout.addWidget(self.qm) self.mainLayout.addWidget(self.permissionsGroup) self.mainLayout.addStretch(1) self.setLayout(self.mainLayout) self.reviewEdit = QTextEdit(self) #定义一个文本编辑控件 self.mainLayout.addWidget(self.reviewEdit) self.reviewEdit.setPlainText('') #帮助文本的内容填入到文本编辑框 self.ts = zldatbase()