class collapsibleGroupBox2(QWidget): def __init__(self, parent=None, title=None): QWidget.__init__(self, parent) self.frame = QFrame(self) self.button = QPushButton("Toggle", self) self.button.setCheckable(True) self.button.setChecked(True) self.switched = False self.vPolicy = None self.button.setStyleSheet(style.collapsibleGroupBoxButton()) if title: self.setTitle(title) def resizeEvent(self, event): if not self.switched: self.switchLayout() return QWidget.resizeEvent(self, event) def switchLayout(self): self.frame.setLayout(self.layout()) self.wLayout = QVBoxLayout(self) self.wLayout.setContentsMargins(0, 0, 0, 0) self.wLayout.setSpacing(0) self.wLayout.addWidget(self.button) self.wLayout.addWidget(self.frame) self.button.toggled.connect(self.setExpanded) self.frame.layout().setContentsMargins(0, 0, 0, 4) self.frame.layout().setSpacing(0) self.switched = True self.vPolicy = self.sizePolicy().verticalPolicy() self.parent().layout().setAlignment(Qt.AlignTop) self.setExpanded(self.button.isChecked()) def setFlat(self, val): if val: self.frame.setFrameShape(QFrame.NoFrame) def setCheckable(self, val): pass def setTitle(self, title): self.button.setText(title) def setExpanded(self, val): self.frame.setVisible(val) if val: self.setSizePolicy(QSizePolicy.Preferred, self.vPolicy) else: self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) def saveState(self): return self.button.isChecked() def restoreState(self, val): self.button.setChecked(val)
def class_selected(self): # the .ui is set to 1 selection for index in self.classes.selectionModel().selectedIndexes(): class_name = self.class_model.data(index, Qt.DisplayRole) self.log.debug("Setting class to {0}".format(class_name)) self.enable_all.setToolTip("Include all permissions in the {0} class.".format(class_name)) self.disable_all.setToolTip("Exclude all permissions in the {0} class.".format(class_name)) self._clear_mappings() # populate new mappings for perm in sorted(self.perm_map.perms(class_name)): # create permission mapping mapping = PermissionMapping(self, perm, self.edit) mapping.setAttribute(Qt.WA_DeleteOnClose) self.class_toggle.connect(mapping.enabled.setChecked) self.perm_mappings.addWidget(mapping) self.widgets.append(mapping) # add horizonal line line = QFrame(self) line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) self.perm_mappings.addWidget(line) self.widgets.append(line)
def __init__(self, *args): super().__init__(BrickletCurrent25, *args) self.cur = self.device self.cbe_current = CallbackEmulator(self.cur.get_current, None, self.cb_current, self.increase_error_count) self.qtcb_over.connect(self.cb_over) self.cur.register_callback(self.cur.CALLBACK_OVER_CURRENT, self.qtcb_over.emit) self.over_label = QLabel('Over Current: No') self.calibrate_button = QPushButton('Calibrate Zero') self.calibrate_button.clicked.connect(self.calibrate_clicked) self.current_current = CurveValueWrapper() # float, A plots = [('Current', Qt.red, self.current_current, format_current)] self.plot_widget = PlotWidget('Current [A]', plots, extra_key_widgets=[self.over_label], y_resolution=0.001) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addWidget(self.calibrate_button)
def __init__(self, *args): super().__init__(BrickletAnalogIn, *args) self.ai = self.device # the firmware version of a EEPROM Bricklet can (under common circumstances) # not change during the lifetime of an EEPROM Bricklet plugin. therefore, # it's okay to make final decisions based on it here self.has_range = self.firmware_version >= (2, 0, 1) self.has_averaging = self.firmware_version >= (2, 0, 3) self.cbe_voltage = CallbackEmulator(self.ai.get_voltage, None, self.cb_voltage, self.increase_error_count) self.current_voltage = CurveValueWrapper() # float, V plots = [('Voltage', Qt.red, self.current_voltage, format_voltage)] self.plot_widget = PlotWidget('Voltage [V]', plots, y_resolution=0.001) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) if self.has_range: self.combo_range = QComboBox() self.combo_range.addItem('Automatic', BrickletAnalogIn.RANGE_AUTOMATIC) if self.has_averaging: self.combo_range.addItem('0 - 3.30 V', BrickletAnalogIn.RANGE_UP_TO_3V) self.combo_range.addItem('0 - 6.05 V', BrickletAnalogIn.RANGE_UP_TO_6V) self.combo_range.addItem('0 - 10.32 V', BrickletAnalogIn.RANGE_UP_TO_10V) self.combo_range.addItem('0 - 36.30 V', BrickletAnalogIn.RANGE_UP_TO_36V) self.combo_range.addItem('0 - 45.00 V', BrickletAnalogIn.RANGE_UP_TO_45V) self.combo_range.currentIndexChanged.connect(self.range_changed) hlayout = QHBoxLayout() hlayout.addWidget(QLabel('Range:')) hlayout.addWidget(self.combo_range) hlayout.addStretch() if self.has_averaging: self.spin_average = QSpinBox() self.spin_average.setMinimum(0) self.spin_average.setMaximum(255) self.spin_average.setSingleStep(1) self.spin_average.setValue(50) self.spin_average.editingFinished.connect(self.spin_average_finished) hlayout.addWidget(QLabel('Average Length:')) hlayout.addWidget(self.spin_average) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self): super().__init__() self.setTitle(translations.TR_WIZARD_PYQT_PROJECT_TITLE_SECOND_PAGE) self.setSubTitle( translations.TR_WIZARD_PYQT_PROJECT_SUBTITLE_SECOND_PAGE) vbox = QVBoxLayout(self) frame = QFrame(self) frame.setFrameShape(QFrame.StyledPanel) vbox.addWidget(frame) # Fields fields_box = QGridLayout(frame) fields_box.addWidget( QLabel(translations.TR_WIZARD_PYQT_CLASS_NAME), 0, 0) self._line_class_name = QLineEdit() self.registerField("class_name*", self._line_class_name) fields_box.addWidget(self._line_class_name, 0, 1) fields_box.addWidget( QLabel(translations.TR_WIZARD_PYQT_BASE_CLASS), 1, 0) self._combo_class_name = QComboBox() self._combo_class_name.addItems(["QWidget", "QMainWindow", "QDialog"]) self.registerField( "base_class", self._combo_class_name, property="currentText") fields_box.addWidget(self._combo_class_name, 1, 1) fields_box.addWidget( QLabel(translations.TR_WIZARD_PYQT_WIDGET_FILE), 2, 0) self._line_widget_file = QLineEdit() self._line_widget_file.setReadOnly(True) fields_box.addWidget(self._line_widget_file, 2, 1) self._combo_class_name.currentTextChanged.connect( self.__update_line_widget) self.__update_line_widget(self._combo_class_name.currentText())
def __init__(self, settings): super(QWidget, self).__init__() self._layout = QBoxLayout(QBoxLayout.TopToBottom) self.setLayout(self._layout) self.settings = settings # eq directory widget = QWidget() layout = QBoxLayout(QBoxLayout.LeftToRight) widget.setLayout(layout) label = QLabel("Everquest Directory: ") layout.addWidget(label) text = QLineEdit() text.setText(self.settings.get_value("general", "eq_directory")) text.setToolTip(self.settings.get_value("general", "eq_directory")) text.setDisabled(True) self._text_eq_directory = text layout.addWidget(text, 1) button = QPushButton("Browse...") button.clicked.connect(self._get_eq_directory) layout.addWidget(button) self._layout.addWidget(widget, 0, Qt.AlignTop) # eq directory info frame = QFrame() frame.setFrameShadow(QFrame.Sunken) frame.setFrameShape(QFrame.Box) frame_layout = QBoxLayout(QBoxLayout.LeftToRight) frame.setLayout(frame_layout) widget = QWidget() layout = QBoxLayout(QBoxLayout.LeftToRight) widget.setLayout(layout) self._label_eq_directory = QLabel() layout.addWidget(self._label_eq_directory, 1) frame_layout.addWidget(widget, 1, Qt.AlignCenter) self._layout.addWidget(frame, 1) # parse interval widget = QWidget() layout = QBoxLayout(QBoxLayout.LeftToRight) widget.setLayout(layout) label = QLabel("Seconds between parse checks: ") layout.addWidget(label, 0, Qt.AlignLeft) text = QLineEdit() text.setText(str(self.settings.get_value("general", "parse_interval"))) text.editingFinished.connect(self._parse_interval_editing_finished) text.setMaxLength(3) self._text_parse_interval = text metrics = QFontMetrics(QApplication.font()) text.setFixedWidth(metrics.width("888888")) layout.addWidget(text, 0, Qt.AlignLeft) self._layout.addWidget(widget, 0, Qt.AlignTop | Qt.AlignLeft) # spacing at bottom of window widget = QWidget() self._layout.addWidget(widget, 1) # setup if settings.get_value("general", "eq_directory") is not None: self._check_directory_stats()
def __init__(self, N=1, parent=None): super(Controller, self).__init__(parent) import interface pumpBackends = interface.initPumps("COM3", N) pumps = [Pump(i) for i in pumpBackends] timer = QTimer(self) for pump in pumps: timer.timeout.connect(pump.update_status) timer.start(1000) divider = QFrame() divider.setFrameShape(QFrame.VLine) mainLayout = QHBoxLayout() mainLayout.addWidget(pumps[0]) for pump in pumps[1:]: mainLayout.addWidget(divider) mainLayout.addWidget(pump) self.setLayout(mainLayout) self.setWindowTitle("Syringe Pump Controller")
def __init__(self): super().__init__() vbox = QVBoxLayout(self) self.setTitle("Python Project") frame = QFrame() frame.setLineWidth(2) vbox.addStretch(1) frame.setFrameShape(QFrame.StyledPanel) vbox.addWidget(frame) box = QGridLayout(frame) box.addWidget(QLabel("Project Name:"), 0, 0) self._line_project_name = QLineEdit() self.registerField("name*", self._line_project_name) box.addWidget(self._line_project_name, 0, 1) box.addWidget(QLabel("Create in:"), 1, 0) self.line = QLineEdit() self.registerField("path", self.line) choose_dir_action = self.line.addAction( QIcon(self.style().standardPixmap( self.style().SP_DirIcon)), QLineEdit.TrailingPosition) box.addWidget(self.line, 1, 1) box.addWidget(QLabel("Interpreter:"), 2, 0) line_interpreter = QComboBox() line_interpreter.setEditable(True) line_interpreter.addItems(utils.get_python()) box.addWidget(line_interpreter, 2, 1) # from ninja_ide.utils import utils choose_dir_action.triggered.connect(self._choose_dir) self.line.setText(utils.get_home_dir())
def __init__(self, *args): super().__init__(BrickletLoadCell, *args) self.lc = self.device self.cbe_weight = CallbackEmulator(self.lc.get_weight, None, self.cb_weight, self.increase_error_count) self.gain = 0 # 128x self.current_weight = CurveValueWrapper() # int, g self.calibration = None plots = [('Weight', Qt.red, self.current_weight, format_weight)] self.plot_widget = PlotWidget('Weight [g]', plots, y_resolution=1.0) self.button_calibration = QPushButton("Calibration...") self.button_calibration.clicked.connect(self.button_calibration_clicked) self.button_tare = QPushButton("Tare") self.button_tare.clicked.connect(self.button_tare_clicked) self.enable_led = QCheckBox("Enable LED") self.enable_led.stateChanged.connect(self.enable_led_changed) self.spin_average = QSpinBox() self.spin_average.setMinimum(0) self.spin_average.setMaximum(40) self.spin_average.setSingleStep(1) self.spin_average.setValue(5) self.spin_average.editingFinished.connect(self.spin_average_finished) self.label_average = QLabel('Moving Average Length:') self.rate_label = QLabel('Rate:') self.rate_combo = QComboBox() self.rate_combo.addItem("10 Hz") self.rate_combo.addItem("80 Hz") self.rate_combo.currentIndexChanged.connect(self.new_config) hlayout = QHBoxLayout() hlayout.addWidget(self.label_average) hlayout.addWidget(self.spin_average) hlayout.addWidget(self.rate_label) hlayout.addWidget(self.rate_combo) hlayout.addStretch() hlayout.addWidget(self.button_calibration) hlayout.addWidget(self.button_tare) hlayout.addWidget(self.enable_led) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): super().__init__(BrickletIndustrialDualAnalogIn, *args) self.analog_in = self.device # the firmware version of a EEPROM Bricklet can (under common circumstances) # not change during the lifetime of an EEPROM Bricklet plugin. therefore, # it's okay to make final decisions based on it here self.has_fixed_calibration = self.firmware_version >= (2, 0, 1) self.cbe_voltage0 = CallbackEmulator(self.analog_in.get_voltage, 0, self.cb_voltage, self.increase_error_count, pass_arguments_to_result_callback=True) self.cbe_voltage1 = CallbackEmulator(self.analog_in.get_voltage, 1, self.cb_voltage, self.increase_error_count, pass_arguments_to_result_callback=True) self.calibration = None self.sample_rate_label = QLabel('Sample Rate:') self.sample_rate_combo = QComboBox() self.sample_rate_combo.addItem('976 Hz') self.sample_rate_combo.addItem('488 Hz') self.sample_rate_combo.addItem('244 Hz') self.sample_rate_combo.addItem('122 Hz') self.sample_rate_combo.addItem('61 Hz') self.sample_rate_combo.addItem('4 Hz') self.sample_rate_combo.addItem('2 Hz') self.sample_rate_combo.addItem('1 Hz') self.current_voltage = [CurveValueWrapper(), CurveValueWrapper()] # float, V self.calibration_button = QPushButton('Calibration...') self.sample_rate_combo.currentIndexChanged.connect(self.sample_rate_combo_index_changed) self.calibration_button.clicked.connect(self.calibration_button_clicked) plots = [('Channel 0', Qt.red, self.current_voltage[0], format_voltage), ('Channel 1', Qt.blue, self.current_voltage[1], format_voltage)] self.plot_widget = PlotWidget('Voltage [V]', plots, y_resolution=0.001) hlayout = QHBoxLayout() hlayout.addWidget(self.sample_rate_label) hlayout.addWidget(self.sample_rate_combo) hlayout.addStretch() hlayout.addWidget(self.calibration_button) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): super().__init__(BrickletUVLightV2, *args) self.uv_light = self.device self.cbe_uva = CallbackEmulator(self.uv_light.get_uva, None, self.cb_uva, self.increase_error_count) self.cbe_uvb = CallbackEmulator(self.uv_light.get_uvb, None, self.cb_uvb, self.increase_error_count) self.cbe_uvi = CallbackEmulator(self.uv_light.get_uvi, None, self.cb_uvi, self.increase_error_count) self.index_label = IndexLabel(' UVI: ? ') self.index_label.setText('0.0') self.current_uva = CurveValueWrapper() self.current_uvb = CurveValueWrapper() plots = [('UVA', Qt.red, self.current_uva, '{} mW/m²'.format), ('UVB', Qt.darkGreen, self.current_uvb, '{} mW/m²'.format)] self.plot_widget = PlotWidget('UV [mW/m²]', plots, extra_key_widgets=[self.index_label], y_resolution=0.1) self.time_label = QLabel('Integration Time:') self.time_combo = QComboBox() self.time_combo.addItem("50 ms", BrickletUVLightV2.INTEGRATION_TIME_50MS) self.time_combo.addItem("100 ms", BrickletUVLightV2.INTEGRATION_TIME_100MS) self.time_combo.addItem("200 ms", BrickletUVLightV2.INTEGRATION_TIME_200MS) self.time_combo.addItem("400 ms", BrickletUVLightV2.INTEGRATION_TIME_400MS) self.time_combo.addItem("800 ms", BrickletUVLightV2.INTEGRATION_TIME_800MS) self.time_combo.currentIndexChanged.connect(self.new_config) self.saturation_label = QLabel('Sensor is saturated, choose a shorter integration time!') self.saturation_label.setStyleSheet('QLabel { color : red }') self.saturation_label.hide() hlayout = QHBoxLayout() hlayout.addWidget(self.time_label) hlayout.addWidget(self.time_combo) hlayout.addStretch() hlayout.addWidget(self.saturation_label) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def initUI(self, haveAuto): vbox = QVBoxLayout(self) top = QFrame(self) top.setFrameShape(QFrame.StyledPanel) bottom = QFrame(self) bottom.setFrameShape(QFrame.StyledPanel) grid1 = QGridLayout() grid1.setSpacing(10) self.lineLabel = [] self.lineEdit = [] for i in range(len(self.label)): self.lineLabel.append(QLabel(self.label[i])) self.lineEdit.append(QLineEdit('%s' % self.value[i])) grid1.addWidget(self.lineLabel[i], i, 0) grid1.addWidget(self.lineEdit[i], i, 1) top.setLayout(grid1) grid2 = QGridLayout() grid2.setSpacing(5) autoButton = QPushButton(self.tr("Auto")) okButton = QPushButton(self.tr("OK")) cancelButton = QPushButton(self.tr("Cancel")) autoButton.clicked.connect(self.cbAuto) okButton.clicked.connect(self.cbOK) cancelButton.clicked.connect(self.cbCancel) if haveAuto: grid2.addWidget(autoButton, 0, 0) grid2.addWidget(okButton, 0, 1) grid2.addWidget(cancelButton, 0, 2) bottom.setLayout(grid2) vbox.addWidget(top) vbox.addWidget(bottom) self.setLayout(vbox) self.resize(50, 50) self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) self.setWindowTitle(self.title) iconWT = QIcon() iconWT.addPixmap(QPixmap(":images/DXF2GCODE-001.ico"), QIcon.Normal, QIcon.Off) self.setWindowIcon(QIcon(iconWT)) self.exec_()
def __init__(self, *args): super().__init__(BrickletPTC, *args) self.ptc = self.device self.str_connected = 'Sensor is <font color="green">connected</font>' self.str_not_connected = 'Sensor is <font color="red">not connected</font>' self.cbe_temperature = CallbackEmulator(self.ptc.get_temperature, None, self.cb_temperature, self.increase_error_count) self.wire_label = QLabel('Wire Type:') self.wire_combo = QComboBox() self.wire_combo.addItem('2-Wire') self.wire_combo.addItem('3-Wire') self.wire_combo.addItem('4-Wire') self.noise_label = QLabel('Noise Rejection Filter:') self.noise_combo = QComboBox() self.noise_combo.addItem('50 Hz') self.noise_combo.addItem('60 Hz') self.connected_label = QLabel(self.str_connected) self.current_temperature = CurveValueWrapper() # float, °C self.wire_combo.currentIndexChanged.connect(self.wire_combo_index_changed) self.noise_combo.currentIndexChanged.connect(self.noise_combo_index_changed) plots = [('Temperature', Qt.red, self.current_temperature, '{} °C'.format)] self.plot_widget = PlotWidget('Temperature [°C]', plots, extra_key_widgets=[self.connected_label], y_resolution=0.01) hlayout = QHBoxLayout() hlayout.addWidget(self.wire_label) hlayout.addWidget(self.wire_combo) hlayout.addStretch() hlayout.addWidget(self.noise_label) hlayout.addWidget(self.noise_combo) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout) self.connected_timer = QTimer(self) self.connected_timer.timeout.connect(self.update_connected) self.connected_timer.setInterval(1000)
def __drawSplitterHandle(self, index): splitterHandle = self.splitter.handle(index) splitterLayout = QVBoxLayout(splitterHandle) splitterLayout.setSpacing(0) splitterLayout.setContentsMargins(0, 0, 0, 0) line = QFrame(splitterHandle) line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) splitterLayout.addWidget(line) splitterHandle.setLayout(splitterLayout)
def __init__(self, parent=None): super().__init__(parent) self.filepath = '' self.layouts = {} self.setWindowModality(Qt.ApplicationModal) self.setWindowTitle('Layout selection') self.setMaximumSize(675, 300) self.setMinimumSize(675, 300) self.resize(675, 300) self.vLayout = QVBoxLayout(self) self.vLayout.setContentsMargins(5, 5, 5, 5) self.hLayout = QHBoxLayout(self) self.vLayout.addLayout(self.hLayout) self.layoutBox = QComboBox(self) self.hLayout.addWidget(self.layoutBox) self.layButton = QPushButton(self) self.layButton.setText('Select layout') self.hLayout.addWidget(self.layButton) self.fileButton = QPushButton(self) self.fileButton.setText('Open file') self.hLayout.addWidget(self.fileButton) self.hLayout.setStretch(0, 3) self.hLayout.setStretch(1, 2) self.hLayout.setStretch(2, 1) line = QFrame(self) line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) self.vLayout.addWidget(line) self.description = QTextBrowser(self) self.vLayout.addWidget(self.description) for layout_class in layouts.get_layouts(): self.layoutBox.addItem(layout_class.NAME) self.layouts[layout_class.NAME] = (layout_class, layout_class.DESCRIPTION) if self.layoutBox.count() == 0: raise Exception('No layout installed!') self.show_description(self.layoutBox.currentText()) self.layoutBox.currentTextChanged.connect(self.show_description) self.layButton.clicked.connect(self.accept) self.fileButton.clicked.connect(self.open_file)
def __init__(self, *args): super().__init__(BrickletHallEffect, *args) self.hf = self.device self.cbe_edge_count = CallbackEmulator(self.get_edge_count, False, self.cb_edge_count, self.increase_error_count, expand_result_tuple_for_callback=True) self.current_value = CurveValueWrapper() self.label_count = CountLabel('Count') plots = [('Value', Qt.red, self.current_value, str)] self.plot_widget = PlotWidget('Value', plots, extra_key_widgets=[self.label_count], update_interval=0.05) self.plot_widget.set_fixed_y_scale(0, 1, 1, 1) self.combo_edge_type = QComboBox() self.combo_edge_type.addItem('Rising') self.combo_edge_type.addItem('Falling') self.combo_edge_type.addItem('Both') self.combo_edge_type.currentIndexChanged.connect(self.edge_changed) self.spin_debounce = QSpinBox() self.spin_debounce.setMinimum(0) self.spin_debounce.setMaximum(255) self.spin_debounce.setValue(100) self.spin_debounce.editingFinished.connect(self.debounce_changed) self.button_reset = QPushButton('Reset Count') self.button_reset.clicked.connect(self.reset_count) hlayout = QHBoxLayout() hlayout.addWidget(QLabel('Edge Type:')) hlayout.addWidget(self.combo_edge_type) hlayout.addStretch() hlayout.addWidget(QLabel('Debounce Period [ms]:')) hlayout.addWidget(self.spin_debounce) hlayout.addStretch() hlayout.addWidget(self.button_reset) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): super().__init__(BrickletMotorizedLinearPoti, *args) self.mp = self.device self.cbe_position = CallbackEmulator(self.mp.get_position, None, self.cb_position, self.increase_error_count) self.current_position = CurveValueWrapper() self.slider = QSlider(Qt.Horizontal) self.slider.setRange(0, 100) self.slider.setMinimumWidth(200) self.slider.setEnabled(False) plots = [('Potentiometer Position', Qt.red, self.current_position, str)] self.plot_widget = PlotWidget('Position', plots, extra_key_widgets=[self.slider], update_interval=0.025, y_resolution=1.0) self.motor_slider = QSlider(Qt.Horizontal) self.motor_slider.setRange(0, 100) self.motor_slider.valueChanged.connect(self.motor_slider_value_changed) self.motor_hold_position = QCheckBox("Hold Position") self.motor_drive_mode = QComboBox() self.motor_drive_mode.addItem('Fast') self.motor_drive_mode.addItem('Smooth') def get_motor_slider_value(): return self.motor_slider.value() self.motor_hold_position.stateChanged.connect(lambda x: self.motor_slider_value_changed(get_motor_slider_value())) self.motor_drive_mode.currentIndexChanged.connect(lambda x: self.motor_slider_value_changed(get_motor_slider_value())) self.motor_position_label = MotorPositionLabel('Motor Target Position:') hlayout = QHBoxLayout() hlayout.addWidget(self.motor_position_label) hlayout.addWidget(self.motor_slider) hlayout.addWidget(self.motor_drive_mode) hlayout.addWidget(self.motor_hold_position) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def initUI(self): self.txt2func = { 'はじめに': Introduction, 'Introduction': Introduction, '分析タスク': TypeOfTask, 'Task': TypeOfTask, '入力データ': SetFile, 'Input data': SetFile, 'データの確認': DataCheck, 'Data check': DataCheck, '過学習': Overfitting, 'Overfitting': Overfitting, '分析の実行': Analysis, 'Analysis': Analysis, '結果の確認': Results, 'Results': Results, 'バイアスとバリアンス': BiasVariance, 'Bias and Variance': BiasVariance, '学習曲線': LearningCurve, 'Learning curve': LearningCurve, '特徴量選択': FeatureSelection, 'Feature selection': FeatureSelection, '結果の確認2': Results2, 'Results 2': Results2, '学習曲線2': LearningCurve2, 'Learning curve 2': LearningCurve2, '予測': Prediction, 'Prediction': Prediction, 'Error': Error} self.setMinimumSize(1280, 960) self.setStyleSheet('background-color: rgb(242, 242, 242)') vbox = QVBoxLayout(self) vbox.setSpacing(0) vbox.setContentsMargins(0, 0, 0, 0) top = QFrame(self) top.setFrameShape(QFrame.StyledPanel) top.setFixedHeight(50) top.setStyleSheet('background-color: white') self.splitter = QSplitter(Qt.Horizontal, self) self.splitter.setHandleWidth(0) self.menuview = MenuView(self.splitter, self.update_content, self.params) self.menuview.setWidgetResizable(True) self.contentview = Introduction(self.splitter, self.menuview.edit_button, self.params) self.contentview.setWidgetResizable(True) self.splitter.addWidget(self.menuview) self.splitter.addWidget(self.contentview) vbox.addWidget(top) vbox.addWidget(self.splitter) self.setLayout(vbox) self.center() # self.showMaximized() self.setWindowTitle('MALSS interactive') self.show()
def __init__(self, *args): super().__init__(BrickletDistanceIRV2, *args) self.dist = self.device self.cbe_distance = CallbackEmulator(self.dist.get_distance, None, self.cb_distance, self.increase_error_count) self.cbe_analog_value = CallbackEmulator(self.dist.get_analog_value, None, self.cb_analog_value, self.increase_error_count) self.analog_label = AnalogLabel('Analog Value:') hlayout = QHBoxLayout() self.average_label = QLabel('Moving Average Length:') self.average_spin = QSpinBox() self.average_spin.setMinimum(1) self.average_spin.setMaximum(1000) self.average_spin.setSingleStep(1) self.average_spin.setValue(25) self.average_spin.editingFinished.connect(self.average_spin_finished) self.sensor_label = QLabel('Sensor Type:') self.sensor_combo = QComboBox() self.sensor_combo.addItem('2Y0A41 (4-30cm)') self.sensor_combo.addItem('2Y0A21 (10-80cm)') self.sensor_combo.addItem('2Y0A02 (20-150cm)') self.sensor_combo.currentIndexChanged.connect(self.sensor_combo_changed) hlayout.addWidget(self.average_label) hlayout.addWidget(self.average_spin) hlayout.addStretch() hlayout.addWidget(self.sensor_label) hlayout.addWidget(self.sensor_combo) self.current_distance = CurveValueWrapper() # float, cm plots = [('Distance', Qt.red, self.current_distance, '{} cm'.format)] self.plot_widget = PlotWidget('Distance [cm]', plots, extra_key_widgets=[self.analog_label], y_resolution=0.1) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, parent=None): super().__init__(parent) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) line = QFrame(self) line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout.addWidget(line) self.text_edit = QTextEdit() self.text_edit.setFixedHeight(100) self.text_edit.setFocusPolicy(Qt.NoFocus) self.text_edit.setReadOnly(True) layout.addWidget(self.text_edit) self.setLayout(layout)
def __init__(self, *args): super().__init__(BrickletAnalogInV3, *args) self.ai = self.device self.cbe_voltage = CallbackEmulator(self.ai.get_voltage, None, self.cb_voltage, self.increase_error_count) self.current_voltage = CurveValueWrapper() # float, V plots = [('Voltage', Qt.red, self.current_voltage, format_voltage)] self.plot_widget = PlotWidget('Voltage [V]', plots, y_resolution=0.001) self.oversampling_combo = QComboBox() self.oversampling_combo.addItem('32x (0.56ms)') self.oversampling_combo.addItem('64x (1.12ms)') self.oversampling_combo.addItem('128x (2.24ms)') self.oversampling_combo.addItem('256x (4.48ms)') self.oversampling_combo.addItem('512x (8.96ms)') self.oversampling_combo.addItem('1024x (17.92ms)') self.oversampling_combo.addItem('2048x (35.84ms)') self.oversampling_combo.addItem('4096x (71.68ms)') self.oversampling_combo.addItem('8192x (143.36ms)') self.oversampling_combo.addItem('16384x (286.72ms)') self.oversampling_combo.currentIndexChanged.connect(self.oversampling_combo_index_changed) self.calibration = None self.calibration_button = QPushButton('Calibration...') self.calibration_button.clicked.connect(self.calibration_button_clicked) layout_h1 = QHBoxLayout() layout_h1.addWidget(QLabel('Oversampling:')) layout_h1.addWidget(self.oversampling_combo) layout_h1.addStretch() layout_h1.addWidget(self.calibration_button) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(layout_h1)
def __init__(self): super().__init__() vbox = QVBoxLayout(self) frame = QFrame(self) vbox.addStretch(1) frame.setFrameShape(QFrame.StyledPanel) vbox.addWidget(frame) # Fields fields_box = QGridLayout(frame) # Project name fields_box.addWidget(QLabel(translations.TR_WIZARD_PROJECT_NAME), 0, 0) self._line_project_name = QLineEdit("untitled") self.registerField("name*", self._line_project_name) fields_box.addWidget(self._line_project_name, 0, 1) # Project location fields_box.addWidget( QLabel(translations.TR_WIZARD_PROJECT_LOCATION), 1, 0) self._line_location = QLineEdit() self._line_location.setReadOnly(True) self._line_location.setText(utils.get_home_dir()) self.registerField("path", self._line_location) choose_dir_act = self._line_location.addAction( self.style().standardIcon( self.style().SP_DirIcon), QLineEdit.TrailingPosition) fields_box.addWidget(self._line_location, 1, 1) # Project description fields_box.addWidget(QLabel(translations.TR_PROJECT_DESCRIPTION), 2, 0) self._txt_desciption = QPlainTextEdit() fields_box.addWidget(self._txt_desciption, 2, 1) self.registerField("description", self._txt_desciption) # Project license fields_box.addWidget(QLabel(translations.TR_PROJECT_LICENSE), 3, 0) combo_license = QComboBox() combo_license.addItems(LICENSES) combo_license.setCurrentIndex(12) fields_box.addWidget(combo_license, 3, 1) self.registerField("license", combo_license, property="currentText") # Project interpreter fields_box.addWidget( QLabel(translations.TR_WIZARD_PROJECT_INTERPRETER), 4, 0) combo_interpreter = QComboBox() combo_interpreter.addItems(utils.get_python()) combo_interpreter.setCurrentText(sys.executable) fields_box.addWidget(combo_interpreter, 4, 1) self.registerField("interpreter", combo_interpreter) # Connections self._line_project_name.textChanged.connect(self._on_text_changed) choose_dir_act.triggered.connect(self._choose_dir)
def initCtrPane(self): # main control set up mainCtr = QFrame(self.ctrPane) mainCtr.setFrameShape(QFrame.StyledPanel) mainCtr.setFrameShadow(QFrame.Sunken) # buttons and controls backSubButton = QPushButton('Background Subtraction', mainCtr) backSubButton.clicked.connect(self.backSub) plotButton = QPushButton('Plot', mainCtr) plotButton.clicked.connect(self.updatePlot1) newTabButton = QPushButton('New tab', mainCtr) newTabButton.clicked.connect(self.addTab) self.plotPeak = QCheckBox('Plot fitted peak', mainCtr) holdPlot = QCheckBox('Hold plot', mainCtr) holdPlot.stateChanged.connect(self.canvas.toggleHold) # layout mainLayout = QGridLayout(mainCtr) mainLayout.addWidget(backSubButton, 0, 0) mainLayout.addWidget(plotButton, 0, 1) mainLayout.addWidget(newTabButton, 1, 0) mainLayout.addWidget(self.plotPeak, 2, 0) mainLayout.addWidget(holdPlot, 2, 1) mainCtr.setLayout(mainLayout) self.ctrPane.addTab(mainCtr, 'Main Control') # NMF control set up NMFCtr = QFrame(self.ctrPane) NMFCtr.setFrameShape(QFrame.StyledPanel) NMFCtr.setFrameShadow(QFrame.Sunken) # input & buttons self.alphaBox = MyDoubleBox(NMFCtr) self.l1RatioBox = MyDoubleBox(NMFCtr) self.loadSettings() NMFButton = QPushButton('NMF', NMFCtr) NMFButton.clicked.connect(self.NMF) # layout NMFLayout = QGridLayout(NMFCtr) NMFLayout.addWidget(QLabel('α'), 0, 0) NMFLayout.addWidget(QLabel('l1 ratio'), 1, 0) NMFLayout.addWidget(self.alphaBox, 0, 1) NMFLayout.addWidget(self.l1RatioBox, 1, 1) NMFLayout.addWidget(NMFButton, 2, 0, 1, 2) NMFCtr.setLayout(NMFLayout) self.ctrPane.addTab(NMFCtr, 'NMF Control')
def __init__(self, *args): super().__init__(BrickletACCurrent, *args) self.acc = self.device self.cbe_current = CallbackEmulator(self.acc.get_current, None, self.cb_current, self.increase_error_count) self.current_current = CurveValueWrapper() # float, A plots = [('Current', Qt.red, self.current_current, format_current)] self.plot_widget = PlotWidget('Current [A]', plots, y_resolution=0.001) self.label_average = QLabel('Moving Average Length:') self.spin_average = QSpinBox() self.spin_average.setMinimum(1) self.spin_average.setMaximum(50) self.spin_average.setSingleStep(1) self.spin_average.setValue(50) self.spin_average.editingFinished.connect(self.spin_average_finished) self.label_range = QLabel('Current Range:') self.combo_range = QComboBox() self.combo_range.addItem("0") # TODO: Adjust ranges self.combo_range.addItem("1") self.combo_range.currentIndexChanged.connect(self.new_config) hlayout = QHBoxLayout() hlayout.addWidget(self.label_average) hlayout.addWidget(self.spin_average) hlayout.addStretch() hlayout.addWidget(self.label_range) hlayout.addWidget(self.combo_range) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): super().__init__(BrickletPressure, *args) self.p = self.device self.cbe_pressure = CallbackEmulator(self.p.get_pressure, None, self.cb_pressure, self.increase_error_count) self.current_pressure = CurveValueWrapper() # float, kPa plots = [('Pressure', Qt.red, self.current_pressure, '{:.3f} kPa'.format)] self.plot_widget = PlotWidget('Pressure [kPa]', plots, y_resolution=0.001) self.combo_sensor = QComboBox() self.combo_sensor.addItem('MPX5500') self.combo_sensor.addItem('MPXV5004') self.combo_sensor.addItem('MPX4115A') self.combo_sensor.currentIndexChanged.connect(self.combo_sensor_changed) self.spin_average = QSpinBox() self.spin_average.setMinimum(1) self.spin_average.setMaximum(50) self.spin_average.setSingleStep(1) self.spin_average.setValue(50) self.spin_average.editingFinished.connect(self.spin_average_finished) hlayout = QHBoxLayout() hlayout.addWidget(QLabel('Sensor Type:')) hlayout.addWidget(self.combo_sensor) hlayout.addStretch() hlayout.addWidget(QLabel('Moving Average Length:')) hlayout.addWidget(self.spin_average) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, gallery, parent=None): super().__init__(parent) self.setWindowFlags(Qt.Window) self.current_chapters = len(gallery.chapters) self.added_chaps = 0 layout = QFormLayout() self.setLayout(layout) lbl = QLabel('{} by {}'.format(gallery.title, gallery.artist)) layout.addRow('Gallery:', lbl) layout.addRow('Current chapters:', QLabel('{}'.format(self.current_chapters))) new_btn = QPushButton('New') new_btn.clicked.connect(self.add_new_chapter) new_btn.adjustSize() add_btn = QPushButton('Finish') add_btn.clicked.connect(self.finish) add_btn.adjustSize() new_l = QHBoxLayout() new_l.addWidget(add_btn, alignment=Qt.AlignLeft) new_l.addWidget(new_btn, alignment=Qt.AlignRight) layout.addRow(new_l) frame = QFrame() frame.setFrameShape(frame.StyledPanel) layout.addRow(frame) self.chapter_l = QVBoxLayout() frame.setLayout(self.chapter_l) new_btn.click() self.setMaximumHeight(550) self.setFixedWidth(500) if parent: self.move(parent.window().frameGeometry().topLeft() + parent.window().rect().center() - self.rect().center()) else: frect = self.frameGeometry() frect.moveCenter(QDesktopWidget().availableGeometry().center()) self.move(frect.topLeft()) self.setWindowTitle('Add Chapters')
def set_paragraph(self, h2='', h3='', text='', img=None): if h2 != '': lbl_h2 = QLabel(h2, self.inner) fnt = lbl_h2.font() fnt.setPointSize(self.H2_FONT_SIZE) lbl_h2.setFont(fnt) lbl_h2.setFixedHeight(self.H2_HEIGHT) lbl_h2.setAlignment(Qt.AlignBottom) lbl_h2.setMargin(self.SIDE_MARGIN) self.vbox.addWidget(lbl_h2) frm = QFrame(self.inner) frm.setFrameShape(QFrame.HLine) frm.setContentsMargins(self.SIDE_MARGIN, 0, self.SIDE_MARGIN, 0) plt = frm.palette() plt.setColor(QPalette.WindowText, Qt.darkGray) frm.setPalette(plt) self.vbox.addWidget(frm) if text != '': lbl_txt = QLabel(text, self.inner) lbl_txt.setWordWrap(True) fnt = lbl_txt.font() fnt.setPointSize(self.TEXT_FONT_SIZE) lbl_txt.setFont(fnt) lbl_txt.setMargin(self.SIDE_MARGIN) self.vbox.addWidget(lbl_txt) if img is not None: if self.params.lang == 'en': img += '_en.png' else: img += '_jp.png' pixmap = QPixmap(img) if not pixmap.isNull(): lbl_img = QLabel(self.inner) lbl_img.setPixmap(pixmap) self.lbl_img_list.append(lbl_img) self.pixmap_list.append(pixmap.scaledToWidth(pixmap.width())) self.vbox.addWidget(lbl_img) self.inner.setLayout(self.vbox)
def __init__(self, *args): super().__init__(BrickletTemperatureIRV2, *args) self.tir = self.device self.cbe_ambient_temperature = CallbackEmulator(self.tir.get_ambient_temperature, None, self.cb_ambient_temperature, self.increase_error_count) self.cbe_object_temperature = CallbackEmulator(self.tir.get_object_temperature, None, self.cb_object_temperature, self.increase_error_count) self.current_ambient = CurveValueWrapper() # float, °C self.current_object = CurveValueWrapper() # float, °C plots = [('Ambient', Qt.blue, self.current_ambient, '{} °C'.format), ('Object', Qt.red, self.current_object, '{} °C'.format)] self.plot_widget = PlotWidget('Temperature [°C]', plots, y_resolution=0.1) self.spin_emissivity = QSpinBox() self.spin_emissivity.setMinimum(6553) self.spin_emissivity.setMaximum(65535) self.spin_emissivity.setValue(65535) self.spin_emissivity.editingFinished.connect(self.spin_emissivity_finished) hlayout = QHBoxLayout() hlayout.addWidget(QLabel('Emissivity:')) hlayout.addWidget(self.spin_emissivity) hlayout.addStretch() line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def initUI(self): hbox = QHBoxLayout(self) topleft = QFrame(self) topleft.setFrameShape(QFrame.StyledPanel) topright = QFrame(self) topright.setFrameShape(QFrame.StyledPanel) bottom = QFrame(self) bottom.setFrameShape(QFrame.StyledPanel) splitter1 = QSplitter(Qt.Horizontal) splitter1.addWidget(topleft) splitter1.addWidget(topright) splitter2 = QSplitter(Qt.Vertical) splitter2.addWidget(splitter1) splitter2.addWidget(bottom) hbox.addWidget(splitter2) self.setLayout(hbox) self.setGeometry(300, 300, 300, 200) self.setWindowTitle('QSplitter') self.show()
def initUI(self, tweet): layout = QGridLayout() self.setLayout(layout) self.lay = layout layout.setColumnStretch(10, 100) self.add_pic() self.add_time() self.add_text() self.add_username() self.add_button() line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout.addWidget(line, 4, 0, 1, -1) self.setLayout(layout) layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0)
class Setting_Ui(QWidget): def __init__(self, persepolis_setting): super().__init__() icon = QtGui.QIcon() self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/icon.svg'))) self.setWindowTitle('Preferences') global icons icons = ':/' + str(persepolis_setting.value('settings/icons')) + '/' self.verticalLayout_2 = QVBoxLayout(self) self.setting_tabWidget = QTabWidget(self) # download_options_tab self.download_options_tab = QWidget() self.layoutWidget = QWidget(self.download_options_tab) self.download_options_verticalLayout = QVBoxLayout(self.layoutWidget) self.download_options_verticalLayout.setContentsMargins(21, 21, 0, 0) self.download_options_verticalLayout.setObjectName( "download_options_verticalLayout") self.horizontalLayout_5 = QHBoxLayout() # tries_label self.tries_label = QLabel(self.layoutWidget) self.horizontalLayout_5.addWidget(self.tries_label) # tries_spinBox self.tries_spinBox = QSpinBox(self.layoutWidget) self.tries_spinBox.setMinimum(1) self.horizontalLayout_5.addWidget(self.tries_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_5) self.horizontalLayout_4 = QHBoxLayout() # wait_label self.wait_label = QLabel(self.layoutWidget) self.horizontalLayout_4.addWidget(self.wait_label) # wait_spinBox self.wait_spinBox = QSpinBox(self.layoutWidget) self.horizontalLayout_4.addWidget(self.wait_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_4) self.horizontalLayout_3 = QHBoxLayout() # time_out_label self.time_out_label = QLabel(self.layoutWidget) self.horizontalLayout_3.addWidget(self.time_out_label) # time_out_spinBox self.time_out_spinBox = QSpinBox(self.layoutWidget) self.horizontalLayout_3.addWidget(self.time_out_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_3) self.horizontalLayout_2 = QHBoxLayout() # connections_label self.connections_label = QLabel(self.layoutWidget) self.horizontalLayout_2.addWidget(self.connections_label) # connections_spinBox self.connections_spinBox = QSpinBox(self.layoutWidget) self.connections_spinBox.setMinimum(1) self.connections_spinBox.setMaximum(16) self.horizontalLayout_2.addWidget(self.connections_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_2) # rpc_port_label self.rpc_port_label = QLabel(self.layoutWidget) self.rpc_horizontalLayout = QHBoxLayout() self.rpc_horizontalLayout.addWidget(self.rpc_port_label) # rpc_port_spinbox self.rpc_port_spinbox = QSpinBox(self.layoutWidget) self.rpc_port_spinbox.setMinimum(1024) self.rpc_port_spinbox.setMaximum(65535) self.rpc_horizontalLayout.addWidget(self.rpc_port_spinbox) self.download_options_verticalLayout.addLayout( self.rpc_horizontalLayout) self.setting_tabWidget.addTab(self.download_options_tab, "") # save_as_tab self.save_as_tab = QWidget() self.layoutWidget1 = QWidget(self.save_as_tab) self.save_as_verticalLayout = QVBoxLayout(self.layoutWidget1) self.save_as_verticalLayout.setContentsMargins(20, 30, 0, 0) self.download_folder_horizontalLayout = QHBoxLayout() # download_folder_label self.download_folder_label = QLabel(self.layoutWidget1) self.download_folder_horizontalLayout.addWidget( self.download_folder_label) # download_folder_lineEdit self.download_folder_lineEdit = QLineEdit(self.layoutWidget1) self.download_folder_horizontalLayout.addWidget( self.download_folder_lineEdit) # download_folder_pushButton self.download_folder_pushButton = QPushButton(self.layoutWidget1) self.download_folder_horizontalLayout.addWidget( self.download_folder_pushButton) self.save_as_verticalLayout.addLayout( self.download_folder_horizontalLayout) self.temp_horizontalLayout = QHBoxLayout() # temp_download_label self.temp_download_label = QLabel(self.layoutWidget1) self.temp_horizontalLayout.addWidget(self.temp_download_label) # temp_download_lineEdit self.temp_download_lineEdit = QLineEdit(self.layoutWidget1) self.temp_horizontalLayout.addWidget(self.temp_download_lineEdit) # temp_download_pushButton self.temp_download_pushButton = QPushButton(self.layoutWidget1) self.temp_horizontalLayout.addWidget(self.temp_download_pushButton) self.save_as_verticalLayout.addLayout(self.temp_horizontalLayout) # create subfolder checkBox self.subfolder_checkBox = QCheckBox(self.layoutWidget1) self.save_as_verticalLayout.addWidget(self.subfolder_checkBox) self.setting_tabWidget.addTab(self.save_as_tab, "") # notifications_tab self.notifications_tab = QWidget() self.layoutWidget2 = QWidget(self.notifications_tab) self.verticalLayout_4 = QVBoxLayout(self.layoutWidget2) self.verticalLayout_4.setContentsMargins(21, 21, 0, 0) # enable_notifications_checkBox self.enable_notifications_checkBox = QCheckBox(self.layoutWidget2) self.verticalLayout_4.addWidget(self.enable_notifications_checkBox) # sound_frame self.sound_frame = QFrame(self.layoutWidget2) self.sound_frame.setFrameShape(QFrame.StyledPanel) self.sound_frame.setFrameShadow(QFrame.Raised) self.verticalLayout = QVBoxLayout(self.sound_frame) # volume_label self.volume_label = QLabel(self.sound_frame) self.verticalLayout.addWidget(self.volume_label) # volume_dial self.volume_dial = QDial(self.sound_frame) self.volume_dial.setProperty("value", 100) self.verticalLayout.addWidget(self.volume_dial) self.verticalLayout_4.addWidget(self.sound_frame) self.setting_tabWidget.addTab(self.notifications_tab, "") # style_tab self.style_tab = QWidget() self.layoutWidget3 = QWidget(self.style_tab) self.verticalLayout_3 = QVBoxLayout(self.layoutWidget3) self.verticalLayout_3.setContentsMargins(21, 21, 0, 0) self.horizontalLayout_8 = QHBoxLayout() # style_label self.style_label = QLabel(self.layoutWidget3) self.horizontalLayout_8.addWidget(self.style_label) # style_comboBox self.style_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_8.addWidget(self.style_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_8) self.horizontalLayout_7 = QHBoxLayout() # color_label self.color_label = QLabel(self.layoutWidget3) self.horizontalLayout_7.addWidget(self.color_label) # color_comboBox self.color_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_7.addWidget(self.color_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_7) # icon_label self.horizontalLayout_12 = QHBoxLayout() self.icon_label = QLabel(self.layoutWidget3) self.horizontalLayout_12.addWidget(self.icon_label) # icon_comboBox self.icon_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_12.addWidget(self.icon_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_12) self.horizontalLayout_6 = QHBoxLayout() # notification_label self.horizontalLayout_13 = QHBoxLayout() self.notification_label = QLabel(self.layoutWidget3) self.horizontalLayout_13.addWidget(self.notification_label) # notification_comboBox self.notification_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_13.addWidget(self.notification_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_13) # font_checkBox self.font_checkBox = QCheckBox(self.layoutWidget3) self.horizontalLayout_6.addWidget(self.font_checkBox) # fontComboBox self.fontComboBox = QFontComboBox(self.layoutWidget3) self.horizontalLayout_6.addWidget(self.fontComboBox) # font_size_label self.font_size_label = QLabel(self.layoutWidget3) self.horizontalLayout_6.addWidget(self.font_size_label) # font_size_spinBox self.font_size_spinBox = QSpinBox(self.layoutWidget3) self.font_size_spinBox.setMinimum(1) self.horizontalLayout_6.addWidget(self.font_size_spinBox) self.verticalLayout_3.addLayout(self.horizontalLayout_6) self.setting_tabWidget.addTab(self.style_tab, "") self.verticalLayout_2.addWidget(self.setting_tabWidget) self.horizontalLayout = QHBoxLayout() spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) # Enable system tray icon self.enable_system_tray_checkBox = QCheckBox(self.layoutWidget3) self.verticalLayout_3.addWidget(self.enable_system_tray_checkBox) # after_download dialog self.after_download_checkBox = QCheckBox() self.verticalLayout_3.addWidget(self.after_download_checkBox) # show_menubar_checkbox self.show_menubar_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.show_menubar_checkbox) # show_sidepanel_checkbox self.show_sidepanel_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.show_sidepanel_checkbox) # hide progress window self.show_progress_window_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.show_progress_window_checkbox) # add persepolis to startup self.startup_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.startup_checkbox) # keep system awake self.keep_awake_checkBox = QCheckBox() self.verticalLayout_3.addWidget(self.keep_awake_checkBox) # columns_tab self.columns_tab = QWidget() layoutWidget4 = QWidget(self.columns_tab) column_verticalLayout = QVBoxLayout(layoutWidget4) column_verticalLayout.setContentsMargins(21, 21, 0, 0) # creating checkBox for columns self.show_column_label = QLabel() self.column0_checkBox = QCheckBox() self.column1_checkBox = QCheckBox() self.column2_checkBox = QCheckBox() self.column3_checkBox = QCheckBox() self.column4_checkBox = QCheckBox() self.column5_checkBox = QCheckBox() self.column6_checkBox = QCheckBox() self.column7_checkBox = QCheckBox() self.column10_checkBox = QCheckBox() self.column11_checkBox = QCheckBox() self.column12_checkBox = QCheckBox() column_verticalLayout.addWidget(self.show_column_label) column_verticalLayout.addWidget(self.column0_checkBox) column_verticalLayout.addWidget(self.column1_checkBox) column_verticalLayout.addWidget(self.column2_checkBox) column_verticalLayout.addWidget(self.column3_checkBox) column_verticalLayout.addWidget(self.column4_checkBox) column_verticalLayout.addWidget(self.column5_checkBox) column_verticalLayout.addWidget(self.column6_checkBox) column_verticalLayout.addWidget(self.column7_checkBox) column_verticalLayout.addWidget(self.column10_checkBox) column_verticalLayout.addWidget(self.column11_checkBox) column_verticalLayout.addWidget(self.column12_checkBox) self.setting_tabWidget.addTab(self.columns_tab, '') # defaults_pushButton self.defaults_pushButton = QPushButton(self) self.horizontalLayout.addWidget(self.defaults_pushButton) # cancel_pushButton self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) self.horizontalLayout.addWidget(self.cancel_pushButton) # ok_pushButton self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) self.horizontalLayout.addWidget(self.ok_pushButton) self.verticalLayout_2.addLayout(self.horizontalLayout) self.setting_tabWidget.setCurrentIndex(3) self.setWindowTitle("Preferences") self.tries_label.setToolTip( "<html><head/><body><p>Set number of tries if download failed.</p></body></html>" ) self.tries_label.setText("Number of tries : ") self.tries_spinBox.setToolTip( "<html><head/><body><p>Set number of tries if download failed.</p></body></html>" ) self.wait_label.setToolTip( "<html><head/><body><p>Set the seconds to wait between retries. Download manager will retry downloads when the HTTP server returns a 503 response.</p></body></html>" ) self.wait_label.setText("Wait between retries (seconds) : ") self.wait_spinBox.setToolTip( "<html><head/><body><p>Set the seconds to wait between retries. Download manager will retry downloads when the HTTP server returns a 503 response.</p></body></html>" ) self.time_out_label.setToolTip( "<html><head/><body><p>Set timeout in seconds. </p></body></html>") self.time_out_label.setText("Time out (seconds) : ") self.time_out_spinBox.setToolTip( "<html><head/><body><p>Set timeout in seconds. </p></body></html>") self.connections_label.setToolTip( "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>" ) self.connections_label.setText("Number of connections : ") self.connections_spinBox.setToolTip( "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>" ) self.rpc_port_label.setText("RPC port number : ") self.rpc_port_spinbox.setToolTip( "<html><head/><body><p> Specify a port number for JSON-RPC/XML-RPC server to listen to. Possible Values: 1024 - 65535 Default: 6801 </p></body></html>" ) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.download_options_tab), "Download Options") self.download_folder_label.setText("Download Folder : ") self.download_folder_pushButton.setText("Change") self.temp_download_label.setText("Temporary Download Folder : ") self.temp_download_pushButton.setText("Change") self.subfolder_checkBox.setText( "Create subfolders for Music,Videos,... in default download folder" ) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.save_as_tab), "Save as") self.enable_notifications_checkBox.setText( "Enable notification sounds") self.volume_label.setText("Volume : ") self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.notifications_tab), "Notifications") self.style_label.setText("Style : ") self.color_label.setText("Color scheme : ") self.icon_label.setText("Icons : ") self.notification_label.setText("Notification type : ") self.font_checkBox.setText("Font : ") self.font_size_label.setText("Size : ") self.enable_system_tray_checkBox.setText("Enable system tray icon.") self.after_download_checkBox.setText( "Show download complete dialog,when download has finished.") self.show_menubar_checkbox.setText("Show menubar.") self.show_sidepanel_checkbox.setText("Show side panel.") self.show_progress_window_checkbox.setText( "Show download's progress window") self.startup_checkbox.setText("Run Persepolis at startup") self.keep_awake_checkBox.setText("Keep system awake!") self.keep_awake_checkBox.setToolTip( "<html><head/><body><p>This option is preventing system from going to sleep.\ This is necessary if your power manager is suspending system automatically. </p></body></html>" ) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.style_tab), "Preferences") # columns_tab self.show_column_label.setText('Show this columns:') self.column0_checkBox.setText('File Name') self.column1_checkBox.setText('Status') self.column2_checkBox.setText('Size') self.column3_checkBox.setText('Downloaded') self.column4_checkBox.setText('Percentage') self.column5_checkBox.setText('Connections') self.column6_checkBox.setText('Transfer rate') self.column7_checkBox.setText('Estimate time left') self.column10_checkBox.setText('First try date') self.column11_checkBox.setText('Last try date') self.column12_checkBox.setText('Category') self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.columns_tab), "Columns customization") # window buttons self.defaults_pushButton.setText("Defaults") self.cancel_pushButton.setText("Cancel") self.ok_pushButton.setText("OK")
def __init__(self, parent=None, aw=None): super(WindowsDlg, self).__init__(parent, aw) self.setWindowTitle( QApplication.translate("Form Caption", "Axes", None)) self.setModal(True) xlimitLabel = QLabel(QApplication.translate("Label", "Max", None)) xlimitLabel_min = QLabel(QApplication.translate("Label", "Min", None)) ylimitLabel = QLabel(QApplication.translate("Label", "Max", None)) ylimitLabel_min = QLabel(QApplication.translate("Label", "Min", None)) zlimitLabel = QLabel(QApplication.translate("Label", "Max", None)) zlimitLabel_min = QLabel(QApplication.translate("Label", "Min", None)) step100Label = QLabel( QApplication.translate("Label", "100% Event Step", None)) self.step100Edit = QLineEdit() self.step100Edit.setMaximumWidth(55) self.step100Edit.setValidator( QIntValidator(self.aw.qmc.ylimit_min_max, 999999, self.step100Edit)) self.step100Edit.setAlignment(Qt.AlignRight) self.step100Edit.setToolTip( QApplication.translate( "Tooltip", "100% event values in step mode are aligned with the given y-axis value or the lowest phases limit if left empty", None)) self.xlimitEdit = QLineEdit() self.xlimitEdit.setMaximumWidth(50) self.xlimitEdit.setMinimumWidth(50) self.xlimitEdit.setAlignment(Qt.AlignRight) self.xlimitEdit_min = QLineEdit() self.xlimitEdit_min.setMaximumWidth(55) self.xlimitEdit_min.setMinimumWidth(55) self.xlimitEdit_min.setAlignment(Qt.AlignRight) regextime = QRegExp(r"^-?[0-9]?[0-9]?[0-9]:[0-5][0-9]$") self.xlimitEdit.setValidator(QRegExpValidator(regextime, self)) self.xlimitEdit_min.setValidator(QRegExpValidator(regextime, self)) self.ylimitEdit = QLineEdit() self.ylimitEdit.setMaximumWidth(60) self.ylimitEdit_min = QLineEdit() self.ylimitEdit_min.setMaximumWidth(60) self.ylimitEdit.setValidator( QIntValidator(self.aw.qmc.ylimit_min_max, self.aw.qmc.ylimit_max, self.ylimitEdit)) self.ylimitEdit_min.setValidator( QIntValidator(self.aw.qmc.ylimit_min_max, self.aw.qmc.ylimit_max, self.ylimitEdit_min)) self.ylimitEdit.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.ylimitEdit_min.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.zlimitEdit = QLineEdit() self.zlimitEdit.setMaximumWidth(60) self.zlimitEdit_min = QLineEdit() self.zlimitEdit_min.setMaximumWidth(60) self.zlimitEdit.setValidator( QIntValidator(self.aw.qmc.zlimit_min_max, self.aw.qmc.zlimit_max, self.zlimitEdit)) self.zlimitEdit_min.setValidator( QIntValidator(self.aw.qmc.zlimit_min_max, self.aw.qmc.zlimit_max, self.zlimitEdit_min)) self.zlimitEdit.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.zlimitEdit_min.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.xlimitEdit.setText(stringfromseconds(self.aw.qmc.endofx)) if self.aw.qmc.timeindex[0] != -1: self.xlimitEdit_min.setText( stringfromseconds(self.aw.qmc.startofx - self.aw.qmc.timex[self.aw.qmc.timeindex[0]])) else: self.xlimitEdit_min.setText(stringfromseconds( self.aw.qmc.startofx)) self.ylimitEdit.setText(str(self.aw.qmc.ylimit)) self.ylimitEdit_min.setText(str(self.aw.qmc.ylimit_min)) if self.aw.qmc.step100temp is not None: self.step100Edit.setText(str(self.aw.qmc.step100temp)) else: self.step100Edit.setText("") self.zlimitEdit.setText(str(self.aw.qmc.zlimit)) self.zlimitEdit_min.setText(str(self.aw.qmc.zlimit_min)) self.legendComboBox = QComboBox() self.legendComboBox.setMaximumWidth(160) legendlocs = [ "", #QApplication.translate("ComboBox", "none",None), QApplication.translate("ComboBox", "upper right", None), QApplication.translate("ComboBox", "upper left", None), QApplication.translate("ComboBox", "lower left", None), QApplication.translate("ComboBox", "lower right", None), QApplication.translate("ComboBox", "right", None), QApplication.translate("ComboBox", "center left", None), QApplication.translate("ComboBox", "center right", None), QApplication.translate("ComboBox", "lower center", None), QApplication.translate("ComboBox", "upper center", None), QApplication.translate("ComboBox", "center", None) ] self.legendComboBox.addItems(legendlocs) self.legendComboBox.setCurrentIndex(self.aw.qmc.legendloc) self.legendComboBox.currentIndexChanged.connect(self.changelegendloc) resettimelabel = QLabel(QApplication.translate("Label", "Max", None)) self.resetEdit = QLineEdit() self.resetEdit.setMaximumWidth(50) self.resetEdit.setMinimumWidth(50) self.resetEdit.setAlignment(Qt.AlignRight) regextime = QRegExp(r"^-?[0-9]?[0-9]?[0-9]:[0-5][0-9]$") self.resetEdit.setValidator(QRegExpValidator(regextime, self)) self.resetEdit.setText(stringfromseconds(self.aw.qmc.resetmaxtime)) self.resetEdit.setToolTip( QApplication.translate("Tooltip", "Time axis max on RESET", None)) # CHARGE min chargeminlabel = QLabel( QApplication.translate("Label", "RESET", None) + " " + QApplication.translate("Label", "Min", None)) self.chargeminEdit = QLineEdit() self.chargeminEdit.setMaximumWidth(50) self.chargeminEdit.setMinimumWidth(50) self.chargeminEdit.setAlignment(Qt.AlignRight) self.chargeminEdit.setValidator(QRegExpValidator(regextime, self)) self.chargeminEdit.setText(stringfromseconds( self.aw.qmc.chargemintime)) self.chargeminEdit.setToolTip( QApplication.translate("Tooltip", "Time axis min on RESET", None)) # fixmaxtime flag self.fixmaxtimeFlag = QCheckBox( QApplication.translate("CheckBox", "Expand", None)) self.fixmaxtimeFlag.setChecked(not self.aw.qmc.fixmaxtime) self.fixmaxtimeFlag.setToolTip( QApplication.translate( "Tooltip", "Automatically extend the time axis by 3min on need", None)) # locktimex flag self.locktimexFlag = QCheckBox( QApplication.translate("CheckBox", "Lock", None)) self.locktimexFlag.setChecked(self.aw.qmc.locktimex) self.locktimexFlag.stateChanged.connect(self.lockTimexFlagChanged) self.locktimexFlag.setToolTip( QApplication.translate( "Tooltip", "Do not set time axis min and max from profile on load", None)) # autotimex flag self.autotimexFlag = QCheckBox( QApplication.translate("CheckBox", "Auto", None)) self.autotimexFlag.setChecked(self.aw.qmc.autotimex) self.autotimexFlag.stateChanged.connect(self.autoTimexFlagChanged) self.autotimexFlag.setToolTip( QApplication.translate( "Tooltip", "Automatically set time axis min and max from profile CHARGE/DROP events", None)) autoButton = QPushButton(QApplication.translate( "Button", "Calc", None)) autoButton.setFocusPolicy(Qt.NoFocus) autoButton.clicked.connect(self.autoAxis) # time axis steps timegridlabel = QLabel(QApplication.translate("Label", "Step", None)) self.xaxislencombobox = QComboBox() timelocs = [ #QApplication.translate("ComboBox", "30 seconds",None), QApplication.translate("ComboBox", "1 minute", None), QApplication.translate("ComboBox", "2 minutes", None), QApplication.translate("ComboBox", "3 minutes", None), QApplication.translate("ComboBox", "4 minutes", None), QApplication.translate("ComboBox", "5 minutes", None), QApplication.translate("ComboBox", "10 minutes", None), QApplication.translate("ComboBox", "30 minutes", None), QApplication.translate("ComboBox", "1 hour", None) ] self.xaxislencombobox.addItems(timelocs) self.xaxislencombobox.setMinimumContentsLength(6) width = self.xaxislencombobox.minimumSizeHint().width() self.xaxislencombobox.setMinimumWidth(width) if platform.system() == 'Darwin': self.xaxislencombobox.setMaximumWidth(width) # self.xaxislencombobox.setMaximumWidth(120) self.timeconversion = [60, 120, 180, 240, 300, 600, 1800, 3600] try: self.xaxislencombobox.setCurrentIndex( self.timeconversion.index(self.aw.qmc.xgrid)) except Exception: self.xaxislencombobox.setCurrentIndex(0) self.xaxislencombobox.currentIndexChanged.connect(self.xaxislenloc) self.timeGridCheckBox = QCheckBox( QApplication.translate("CheckBox", "Time", None)) self.timeGridCheckBox.setChecked(self.aw.qmc.time_grid) self.timeGridCheckBox.setToolTip( QApplication.translate("Tooltip", "Show time grid", None)) self.timeGridCheckBox.setFocusPolicy(Qt.NoFocus) self.tempGridCheckBox = QCheckBox( QApplication.translate("CheckBox", "Temp", None)) self.tempGridCheckBox.setToolTip( QApplication.translate("Tooltip", "Show temperature grid", None)) self.tempGridCheckBox.setChecked(self.aw.qmc.temp_grid) self.tempGridCheckBox.setFocusPolicy(Qt.NoFocus) ygridlabel = QLabel(QApplication.translate("Label", "Step", None)) self.ygridSpinBox = QSpinBox() self.ygridSpinBox.setRange(10, 500) self.ygridSpinBox.setSingleStep(5) self.ygridSpinBox.setValue(self.aw.qmc.ygrid) self.ygridSpinBox.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.ygridSpinBox.valueChanged.connect(self.changeygrid) self.ygridSpinBox.setMaximumWidth(60) zgridlabel = QLabel(QApplication.translate("Label", "Step", None)) self.zgridSpinBox = QSpinBox() self.zgridSpinBox.setRange(1, 100) self.zgridSpinBox.setSingleStep(5) self.zgridSpinBox.setValue(self.aw.qmc.zgrid) self.zgridSpinBox.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.zgridSpinBox.valueChanged.connect(self.changezgrid) self.zgridSpinBox.setMaximumWidth(60) self.autodeltaxLabel = QLabel( QApplication.translate("CheckBox", "Auto", None)) self.autodeltaxETFlag = QCheckBox( deltaLabelUTF8 + QApplication.translate("CheckBox", "ET", None)) self.autodeltaxETFlag.setChecked(self.aw.qmc.autodeltaxET) self.autodeltaxBTFlag = QCheckBox( deltaLabelUTF8 + QApplication.translate("CheckBox", "BT", None)) self.autodeltaxBTFlag.setChecked(self.aw.qmc.autodeltaxBT) self.autodeltaxETFlag.setToolTip( QApplication.translate( "Tooltip", "Automatically set delta axis max from DeltaET", None)) self.autodeltaxBTFlag.setToolTip( QApplication.translate( "Tooltip", "Automatically set delta axis max from DeltaBT", None)) autoDeltaButton = QPushButton( QApplication.translate("Button", "Calc", None)) autoDeltaButton.setFocusPolicy(Qt.NoFocus) autoDeltaButton.clicked.connect(self.autoDeltaAxis) linestylegridlabel = QLabel( QApplication.translate("Label", "Style", None)) self.gridstylecombobox = QComboBox() gridstyles = [ QApplication.translate("ComboBox", "solid", None), QApplication.translate("ComboBox", "dashed", None), QApplication.translate("ComboBox", "dashed-dot", None), QApplication.translate("ComboBox", "dotted", None), QApplication.translate("ComboBox", "None", None) ] self.gridstylecombobox.addItems(gridstyles) self.gridstylecombobox.setCurrentIndex(self.aw.qmc.gridlinestyle) self.gridstylecombobox.currentIndexChanged.connect( self.changegridstyle) gridthicknesslabel = QLabel( QApplication.translate("Label", "Width", None)) self.gridwidthSpinBox = QSpinBox() self.gridwidthSpinBox.setRange(1, 5) self.gridwidthSpinBox.setValue(self.aw.qmc.gridthickness) self.gridwidthSpinBox.valueChanged.connect(self.changegridwidth) self.gridwidthSpinBox.setMaximumWidth(40) self.gridwidthSpinBox.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) gridalphalabel = QLabel( QApplication.translate("Label", "Opaqueness", None)) self.gridalphaSpinBox = QSpinBox() self.gridalphaSpinBox.setRange(1, 10) self.gridalphaSpinBox.setValue(int(self.aw.qmc.gridalpha * 10)) self.gridalphaSpinBox.valueChanged.connect(self.changegridalpha) self.gridalphaSpinBox.setMaximumWidth(40) self.gridalphaSpinBox.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) # connect the ArtisanDialog standard OK/Cancel buttons self.dialogbuttons.accepted.connect(self.updatewindow) self.dialogbuttons.rejected.connect(self.close) resetButton = self.dialogbuttons.addButton( QDialogButtonBox.RestoreDefaults) resetButton.clicked.connect(self.reset) if self.aw.locale not in self.aw.qtbase_locales: resetButton.setText( QApplication.translate("Button", "Defaults", None)) self.loadAxisFromProfile = QCheckBox( QApplication.translate("CheckBox", "Load from profile", None)) self.loadAxisFromProfile.setChecked(self.aw.qmc.loadaxisfromprofile) hline = QFrame() hline.setFrameShape(QFrame.HLine) hline.setFrameShadow(QFrame.Sunken) hline2 = QFrame() hline2.setFrameShape(QFrame.HLine) hline2.setFrameShadow(QFrame.Sunken) xlayout1 = QHBoxLayout() xlayout1.addWidget(self.autotimexFlag) xlayout1.addWidget(autoButton) xlayout1.addStretch() xlayout1.addWidget(self.locktimexFlag) xlayout2 = QHBoxLayout() xlayout2.addWidget(xlimitLabel_min) xlayout2.addWidget(self.xlimitEdit_min) xlayout2.addSpacing(10) xlayout2.addWidget(xlimitLabel) xlayout2.addWidget(self.xlimitEdit) xlayout2.addStretch() xlayout2.addWidget(timegridlabel) xlayout2.addWidget(self.xaxislencombobox) xlayout3 = QHBoxLayout() xlayout3.addWidget(chargeminlabel) xlayout3.addWidget(self.chargeminEdit) xlayout3.addSpacing(7) xlayout3.addWidget(resettimelabel) xlayout3.addWidget(self.resetEdit) xlayout3.addSpacing(7) xlayout3.addStretch() xlayout3.addWidget(self.fixmaxtimeFlag) xlayout = QVBoxLayout() xlayout.addLayout(xlayout1) xlayout.addLayout(xlayout2) xlayout.addWidget(hline) xlayout.addLayout(xlayout3) ylayout = QGridLayout() ylayout.addWidget(ylimitLabel_min, 0, 0, Qt.AlignRight) ylayout.addWidget(self.ylimitEdit_min, 0, 1) ylayout.addWidget(ylimitLabel, 0, 3, Qt.AlignRight) ylayout.addWidget(self.ylimitEdit, 0, 4) ylayout.addWidget(ygridlabel, 0, 6, Qt.AlignRight) ylayout.addWidget(self.ygridSpinBox, 0, 7) ylayout.setColumnMinimumWidth(2, 10) ylayout.setColumnMinimumWidth(5, 10) ylayoutHbox = QHBoxLayout() ylayoutHbox.addStretch() ylayoutHbox.addLayout(ylayout) ylayoutHbox.addStretch() steplayoutHbox = QHBoxLayout() steplayoutHbox.addWidget(step100Label) steplayoutHbox.addWidget(self.step100Edit) steplayoutHbox.addStretch() ylayoutVbox = QVBoxLayout() ylayoutVbox.addLayout(ylayoutHbox) ylayoutVbox.addWidget(hline) ylayoutVbox.addLayout(steplayoutHbox) ylayoutVbox.addStretch() zlayout1 = QHBoxLayout() zlayout1.addWidget(self.autodeltaxLabel) zlayout1.addSpacing(5) zlayout1.addWidget(self.autodeltaxETFlag) zlayout1.addSpacing(5) zlayout1.addWidget(self.autodeltaxBTFlag) zlayout1.addSpacing(5) zlayout1.addWidget(autoDeltaButton) zlayout1.addStretch() zlayout = QGridLayout() zlayout.addWidget(zlimitLabel_min, 0, 0, Qt.AlignRight) zlayout.addWidget(self.zlimitEdit_min, 0, 1) zlayout.addWidget(zlimitLabel, 0, 3, Qt.AlignRight) zlayout.addWidget(self.zlimitEdit, 0, 4) zlayout.addWidget(zgridlabel, 0, 6, Qt.AlignRight) zlayout.addWidget(self.zgridSpinBox, 0, 7) zlayout.setColumnMinimumWidth(2, 10) zlayout.setColumnMinimumWidth(5, 10) zlayoutHbox = QHBoxLayout() zlayoutHbox.addStretch() zlayoutHbox.addLayout(zlayout) zlayoutHbox.addStretch() zlayoutVbox = QVBoxLayout() zlayoutVbox.addLayout(zlayout1) zlayoutVbox.addLayout(zlayoutHbox) zlayoutVbox.addStretch() legentlayout = QHBoxLayout() legentlayout.addStretch() legentlayout.addWidget(self.legendComboBox, 0, Qt.AlignLeft) legentlayout.addStretch() graphgridlayout = QGridLayout() graphgridlayout.addWidget(linestylegridlabel, 1, 0, Qt.AlignRight) graphgridlayout.addWidget(self.gridstylecombobox, 1, 1, Qt.AlignLeft) graphgridlayout.addWidget(gridthicknesslabel, 1, 2, Qt.AlignRight) graphgridlayout.addWidget(self.gridwidthSpinBox, 1, 3, Qt.AlignLeft) graphgridlayout.addWidget(self.timeGridCheckBox, 2, 0, Qt.AlignLeft) graphgridlayout.addWidget(self.tempGridCheckBox, 2, 1, Qt.AlignLeft) graphgridlayout.addWidget(gridalphalabel, 2, 2, Qt.AlignRight) graphgridlayout.addWidget(self.gridalphaSpinBox, 2, 3, Qt.AlignLeft) xGroupLayout = QGroupBox( QApplication.translate("GroupBox", "Time Axis", None)) xGroupLayout.setLayout(xlayout) yGroupLayout = QGroupBox( QApplication.translate("GroupBox", "Temperature Axis", None)) yGroupLayout.setLayout(ylayoutVbox) zGroupLayout = QGroupBox( deltaLabelUTF8 + " " + QApplication.translate("GroupBox", "Axis", None)) zGroupLayout.setLayout(zlayoutVbox) legendLayout = QGroupBox( QApplication.translate("GroupBox", "Legend Location", None)) legendLayout.setLayout(legentlayout) GridGroupLayout = QGroupBox( QApplication.translate("GroupBox", "Grid", None)) GridGroupLayout.setLayout(graphgridlayout) buttonLayout = QHBoxLayout() buttonLayout.addWidget(self.loadAxisFromProfile) buttonLayout.addSpacing(10) buttonLayout.addWidget(self.dialogbuttons) mainLayout1 = QVBoxLayout() mainLayout1.addWidget(xGroupLayout) mainLayout1.addWidget(yGroupLayout) mainLayout1.addStretch() mainLayout2 = QVBoxLayout() mainLayout2.addWidget(legendLayout) mainLayout2.addWidget(GridGroupLayout) mainLayout2.addWidget(zGroupLayout) mainLayout2.addStretch() mainHLayout = QHBoxLayout() mainHLayout.addLayout(mainLayout1) mainHLayout.addLayout(mainLayout2) mainLayout = QVBoxLayout() mainLayout.addLayout(mainHLayout) mainLayout.addStretch() mainLayout.addLayout(buttonLayout) self.setLayout(mainLayout) self.dialogbuttons.button(QDialogButtonBox.Ok).setFocus() if self.aw.qmc.locktimex: self.disableXAxisControls() else: self.enableXAxisControls() settings = QSettings() if settings.contains("AxisPosition"): self.move(settings.value("AxisPosition")) mainLayout.setSizeConstraint(QLayout.SetFixedSize)
def vertical_separator() -> QWidget: line = QFrame() line.setFrameShape(QFrame.VLine) line.setFrameShadow(QFrame.Sunken) return line
def __init__(self, *args): super().__init__(BrickletIndustrialDual020mAV2, *args) self.dual020 = self.device self.str_connected = 'Channel {0} is <font color="green">connected</font>' self.str_not_connected = 'Channel {0} is <font color="red">not connected</font>' self.cbe_current0 = CallbackEmulator( self.dual020.get_current, 0, self.cb_current, self.increase_error_count, pass_arguments_to_result_callback=True) self.cbe_current1 = CallbackEmulator( self.dual020.get_current, 1, self.cb_current, self.increase_error_count, pass_arguments_to_result_callback=True) self.connected_labels = [ FixedSizeLabel(self.str_not_connected.format(0)), FixedSizeLabel(self.str_not_connected.format(1)) ] self.current_current = [CurveValueWrapper(), CurveValueWrapper()] # float, mA plots = [('Channel 0', Qt.red, self.current_current[0], lambda value: '{:.03f} mA'.format(round(value, 3))), ('Channel 1', Qt.blue, self.current_current[1], lambda value: '{:.03f} mA'.format(round(value, 3)))] self.plot_widget = PlotWidget('Current [mA]', plots, extra_key_widgets=self.connected_labels, y_resolution=0.001) h_sp = QSizePolicy() h_sp.setHorizontalPolicy(QSizePolicy.Expanding) self.sample_rate_label = QLabel('Sample Rate:') self.sample_rate_combo = QComboBox() self.sample_rate_combo.addItem('240 Hz') self.sample_rate_combo.addItem('60 Hz') self.sample_rate_combo.addItem('15 Hz') self.sample_rate_combo.addItem('4 Hz') self.sample_rate_combo.currentIndexChanged.connect( self.sample_rate_combo_index_changed) self.sample_rate_combo.setSizePolicy(h_sp) self.gain_label = QLabel('Gain:') self.gain_combo = QComboBox() self.gain_combo.addItem('x1') self.gain_combo.addItem('x2') self.gain_combo.addItem('x4') self.gain_combo.addItem('x8') self.gain_combo.currentIndexChanged.connect( self.gain_combo_index_changed) self.gain_combo.setSizePolicy(h_sp) self.led_config_ch0_label = QLabel('Channel 0') self.led_config_ch1_label = QLabel('Channel 1') self.led_config_label = QLabel('LED Config:') self.led_status_config_label = QLabel('LED Status Config:') self.led_status_config_ch0_min_label = QLabel('Min:') self.led_status_config_ch0_max_label = QLabel('Max:') self.led_status_config_ch1_min_label = QLabel('Min:') self.led_status_config_ch1_max_label = QLabel('Max:') self.led_config_ch0_combo = QComboBox() self.led_config_ch0_combo.addItem('Off') self.led_config_ch0_combo.addItem('On') self.led_config_ch0_combo.addItem('Show Heartbeat') self.led_config_ch0_combo.addItem('Show Channel Status') self.led_config_ch0_combo.setSizePolicy(h_sp) self.led_config_ch0_combo.currentIndexChanged.connect( self.led_config_ch0_combo_changed) self.led_config_ch1_combo = QComboBox() self.led_config_ch1_combo.addItem('Off') self.led_config_ch1_combo.addItem('On') self.led_config_ch1_combo.addItem('Show Heartbeat') self.led_config_ch1_combo.addItem('Show Channel Status') self.led_config_ch1_combo.setSizePolicy(h_sp) self.led_config_ch1_combo.currentIndexChanged.connect( self.led_config_ch1_combo_changed) self.led_status_config_ch0_combo = QComboBox() self.led_status_config_ch0_combo.addItem('Threshold') self.led_status_config_ch0_combo.addItem('Intensity') self.led_status_config_ch0_combo.setSizePolicy(h_sp) self.led_status_config_ch0_combo.currentIndexChanged.connect( self.led_status_config_ch0_combo_changed) self.led_status_config_ch1_combo = QComboBox() self.led_status_config_ch1_combo.addItem('Threshold') self.led_status_config_ch1_combo.addItem('Intensity') self.led_status_config_ch1_combo.setSizePolicy(h_sp) self.led_status_config_ch1_combo.currentIndexChanged.connect( self.led_status_config_ch1_combo_changed) self.led_status_config_ch0_min_sbox = QDoubleSpinBox() self.led_status_config_ch0_max_sbox = QDoubleSpinBox() self.led_status_config_ch1_min_sbox = QDoubleSpinBox() self.led_status_config_ch1_max_sbox = QDoubleSpinBox() self.led_status_config_ch0_min_sbox.setValue(0) self.led_status_config_ch0_min_sbox.setMinimum(0) self.led_status_config_ch0_min_sbox.setSingleStep(0.5) self.led_status_config_ch0_min_sbox.setDecimals(3) self.led_status_config_ch0_min_sbox.setSuffix(' mA') self.led_status_config_ch0_min_sbox.setMaximum(22.5) self.led_status_config_ch0_min_sbox.valueChanged.connect( self.led_status_config_ch0_min_sbox_changed) self.led_status_config_ch0_max_sbox.setValue(0) self.led_status_config_ch0_max_sbox.setMinimum(0) self.led_status_config_ch0_max_sbox.setSingleStep(0.5) self.led_status_config_ch0_max_sbox.setDecimals(3) self.led_status_config_ch0_max_sbox.setSuffix(' mA') self.led_status_config_ch0_max_sbox.setMaximum(22.5) self.led_status_config_ch0_max_sbox.valueChanged.connect( self.led_status_config_ch0_max_sbox_changed) self.led_status_config_ch1_min_sbox.setValue(0) self.led_status_config_ch1_min_sbox.setMinimum(0) self.led_status_config_ch1_min_sbox.setSingleStep(0.5) self.led_status_config_ch1_min_sbox.setDecimals(3) self.led_status_config_ch1_min_sbox.setSuffix(' mA') self.led_status_config_ch1_min_sbox.setMaximum(22.5) self.led_status_config_ch1_min_sbox.valueChanged.connect( self.led_status_config_ch1_min_sbox_changed) self.led_status_config_ch1_max_sbox.setValue(0) self.led_status_config_ch1_max_sbox.setMinimum(0) self.led_status_config_ch1_max_sbox.setSingleStep(0.5) self.led_status_config_ch1_max_sbox.setDecimals(3) self.led_status_config_ch1_max_sbox.setSuffix(' mA') self.led_status_config_ch1_max_sbox.setMaximum(22.5) self.led_status_config_ch1_max_sbox.valueChanged.connect( self.led_status_config_ch1_max_sbox_changed) hlayout = QHBoxLayout() self.led_status_config_ch0_min_sbox.setSizePolicy(h_sp) self.led_status_config_ch0_max_sbox.setSizePolicy(h_sp) hlayout.addWidget(self.led_status_config_ch0_min_label) hlayout.addWidget(self.led_status_config_ch0_min_sbox) hlayout.addWidget(self.led_status_config_ch0_max_label) hlayout.addWidget(self.led_status_config_ch0_max_sbox) hlayout1 = QHBoxLayout() self.led_status_config_ch1_min_sbox.setSizePolicy(h_sp) self.led_status_config_ch1_max_sbox.setSizePolicy(h_sp) hlayout1.addWidget(self.led_status_config_ch1_min_label) hlayout1.addWidget(self.led_status_config_ch1_min_sbox) hlayout1.addWidget(self.led_status_config_ch1_max_label) hlayout1.addWidget(self.led_status_config_ch1_max_sbox) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) line1 = QFrame() line1.setObjectName("line1") line1.setFrameShape(QFrame.HLine) line1.setFrameShadow(QFrame.Sunken) line2 = QFrame() line2.setObjectName("line2") line2.setFrameShape(QFrame.HLine) line2.setFrameShadow(QFrame.Sunken) glayout = QGridLayout() glayout.addWidget(line, 0, 0, 1, 3) # line-1 glayout.addWidget(self.sample_rate_label, 1, 0, 1, 1) glayout.addWidget(self.sample_rate_combo, 1, 1, 1, 2) glayout.addWidget(self.gain_label, 2, 0, 1, 1) glayout.addWidget(self.gain_combo, 2, 1, 1, 2) glayout.addWidget(line1, 3, 0, 1, 3) # line-2 glayout.addWidget(self.led_config_ch0_label, 4, 1, 1, 1) glayout.addWidget(self.led_config_ch1_label, 4, 2, 1, 1) glayout.addWidget(line2, 5, 0, 1, 3) # line-3 glayout.addWidget(self.led_config_label, 6, 0, 1, 1) glayout.addWidget(self.led_config_ch0_combo, 6, 1, 1, 1) glayout.addWidget(self.led_config_ch1_combo, 6, 2, 1, 1) glayout.addWidget(self.led_status_config_label, 7, 0, 1, 1) glayout.addWidget(self.led_status_config_ch0_combo, 7, 1, 1, 1) glayout.addWidget(self.led_status_config_ch1_combo, 7, 2, 1, 1) glayout.addLayout(hlayout, 8, 1, 1, 1) glayout.addLayout(hlayout1, 8, 2, 1, 1) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addLayout(glayout) self.ui_group_ch_status_ch0 = [ self.led_status_config_ch0_combo, self.led_status_config_ch0_min_sbox, self.led_status_config_ch0_max_sbox ] self.ui_group_ch_status_ch1 = [ self.led_status_config_ch1_combo, self.led_status_config_ch1_min_sbox, self.led_status_config_ch1_max_sbox ]
def initUI(self): # region vbox1 Overview vbox1 = QVBoxLayout() vbox1.setAlignment(Qt.AlignCenter) # model selection & input image grid_input = QGridLayout() font_bold = QFont() font_bold.setBold(True) lbl_model = QLabel('Model') lbl_model.setFont(font_bold) combo_model = QComboBox(self) combo_model.addItem('') model_names = self.model.get_data( CNN_Vis_Demo_Model.data_idx_model_names) for model_name in model_names: combo_model.addItem(model_name) combo_model.activated[str].connect(self.ctl.set_model) lbl_input = QLabel('Input') lbl_input.setFont(font_bold) self.combo_input_source = QComboBox(self) self.combo_input_source.addItem('') # null entry self.combo_input_source.addItem('Image') self.combo_input_source.addItem('Video') self.combo_input_source.activated[str].connect(self.ctl.switch_source) self.combo_input_source.setCurrentText('Image') self.combo_input_source.setEnabled(False) self.combo_input_image = QComboBox(self) self.combo_input_image.addItem('') # null entry self.combo_input_image.activated[str].connect(self.ctl.set_input_image) self.combo_input_image.setEnabled(False) grid_input.addWidget(lbl_model, 0, 1) grid_input.addWidget(combo_model, 0, 2) grid_input.addWidget(lbl_input, 1, 1) grid_input.addWidget(self.combo_input_source, 1, 2) grid_input.addWidget(self.combo_input_image, 2, 1, 1, 2) vbox1.addLayout(grid_input) # input image pixm_input = QPixmap(QSize(224, 224)) pixm_input.fill(Qt.black) self.lbl_input_image = DoubleClickableQLabel() self.lbl_input_image.setAlignment(Qt.AlignCenter) self.lbl_input_image.setPixmap(pixm_input) vbox1.addWidget(self.lbl_input_image) # Arrow lbl_arrow_input_to_NN = QLabel('⬇️') lbl_arrow_input_to_NN.setFont(font_bold) lbl_arrow_input_to_NN.setAlignment(Qt.AlignCenter) vbox1.addWidget(lbl_arrow_input_to_NN) # Network overview gb_network = QGroupBox("Convolutional Neural network") self.scroll_network = QScrollArea() self.scroll_network.setFrameShape(QFrame.Box) self.scroll_network.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.scroll_network.setAlignment(Qt.AlignCenter) self.draw_network_overview() layout_scroll_network = QVBoxLayout() layout_scroll_network.addWidget(self.scroll_network) gb_network.setLayout(layout_scroll_network) vbox1.addWidget(gb_network) # Arrow lbl_arrow_NN_to_probs = QLabel('⬇️') lbl_arrow_NN_to_probs.setFont(font_bold) lbl_arrow_NN_to_probs.setAlignment(Qt.AlignCenter) vbox1.addWidget(lbl_arrow_NN_to_probs) # Prob view self.probs_view = ProbsView() vbox1.addWidget(self.probs_view) # endregion # region vbox2 layer view vbox2 = QVBoxLayout() vbox2.setAlignment(Qt.AlignTop) # header self.combo_layer_view = QComboBox(self) self.combo_layer_view.addItem('Activations') self.combo_layer_view.addItem('Top 1 images') self.combo_layer_view.currentTextChanged.connect(self.load_layer_view) selected_layer_name = ' ' self.lbl_layer_name = QLabel( "of layer <font color='blue'><b>%r</b></font>" % selected_layer_name) grid_layer_header = QGridLayout() grid_layer_header.addWidget(self.combo_layer_view, 0, 1) grid_layer_header.addWidget(self.lbl_layer_name, 0, 2) vbox2.addLayout(grid_layer_header) # layer view self.layer_view = LayerViewWidget(None) self.layer_view.clicked_unit_changed.connect(self.select_unit_action) vbox2.addWidget(self.layer_view) # endregion # region vbox3 vbox3 = QVBoxLayout() vbox3.setAlignment(Qt.AlignTop) # region unit view # todo: make a customized widget for this region? # header self.combo_unit_view = QComboBox(self) for member in DetailedUnitViewWidget.WorkingMode: self.combo_unit_view.addItem(member.value) self.combo_unit_view.currentTextChanged.connect( self.load_detailed_unit_image) self.combo_unit_view.setCurrentText( DetailedUnitViewWidget.WorkingMode.ACTIVATION.value) selected_unit_name = ' ' self.lbl_unit_name = QLabel( "of unit <font color='blue'><b>%r</b></font>" % selected_unit_name) hbox_unit_view_header = QHBoxLayout() hbox_unit_view_header.addWidget(self.combo_unit_view) hbox_unit_view_header.addWidget(self.lbl_unit_name) vbox3.addLayout(hbox_unit_view_header) # overlay setting hbox_overlay = QHBoxLayout() hbox_overlay.addWidget(QLabel("Overlay: ")) self.combo_unit_overlay = QComboBox(self) for member in DetailedUnitViewWidget.OverlayOptions: self.combo_unit_overlay.addItem(member.value) self.combo_unit_overlay.activated[str].connect(self.overlay_action) hbox_overlay.addWidget(self.combo_unit_overlay) vbox3.addLayout(hbox_overlay) # Backprop Mode setting hbox_backprop_mode = QHBoxLayout() hbox_backprop_mode.addWidget(QLabel("Backprop mode: ")) self.combo_unit_backprop_mode = QComboBox(self) for member in self.model.BackpropModeOption: self.combo_unit_backprop_mode.addItem(member.value) self.combo_unit_backprop_mode.currentTextChanged.connect( self.load_detailed_unit_image) self.combo_unit_backprop_mode.setEnabled(False) hbox_backprop_mode.addWidget(self.combo_unit_backprop_mode) vbox3.addLayout(hbox_backprop_mode) # Backprop view setting hbox_backprop_view = QHBoxLayout() hbox_backprop_view.addWidget(QLabel("Backprop view: ")) self.combo_unit_backprop_view = QComboBox(self) for member in DetailedUnitViewWidget.BackpropViewOption: self.combo_unit_backprop_view.addItem(member.value) self.combo_unit_backprop_view.setCurrentText( DetailedUnitViewWidget.BackpropViewOption.RAW.value) self.combo_unit_backprop_view.currentTextChanged.connect( self.switch_backprop_view_action) self.combo_unit_backprop_view.setEnabled(False) hbox_backprop_view.addWidget(self.combo_unit_backprop_view) vbox3.addLayout(hbox_backprop_view) # unit image self.detailed_unit_view = DetailedUnitViewWidget() vbox3.addWidget(self.detailed_unit_view) # endregion # spacer vbox3.addSpacing(20) frm_line_unit_top9 = QFrame() frm_line_unit_top9.setFrameShape(QFrame.HLine) frm_line_unit_top9.setFrameShadow(QFrame.Sunken) frm_line_unit_top9.setLineWidth(1) vbox3.addWidget(frm_line_unit_top9) vbox3.addSpacing(20) # top 9 images vbox3.addWidget(QLabel("Top 9 images with highest activations")) self.combo_top9_images_mode = QComboBox(self) self.combo_top9_images_mode.addItem("Input") self.combo_top9_images_mode.addItem("Deconv") self.combo_top9_images_mode.currentTextChanged.connect( self.load_top_images) vbox3.addWidget(self.combo_top9_images_mode) self.grid_top9 = QGridLayout() self.last_shown_unit_info = { 'model_name': 'dummy_model_name', 'layer': 'dummy_layer', 'channel': -1 } pixm_top_image = QPixmap(QSize(224, 224)) pixm_top_image.fill(Qt.darkGray) _top_image_height = 64 pixm_top_image_scaled = pixm_top_image.scaledToHeight( _top_image_height) positions_top9_images = [(i, j) for i in range(3) for j in range(3)] for position in positions_top9_images: lbl_top_image = QLabel() lbl_top_image.setPixmap(pixm_top_image_scaled) lbl_top_image.setFixedSize( QSize(_top_image_height + 4, _top_image_height + 4)) self.grid_top9.addWidget(lbl_top_image, *position) vbox3.addLayout(self.grid_top9) # spacer # vbox3.addSpacing(20) # frm_line_top9_gd = QFrame() # frm_line_top9_gd.setFrameShape(QFrame.HLine) # frm_line_top9_gd.setFrameShadow(QFrame.Sunken) # frm_line_top9_gd.setLineWidth(1) # vbox3.addWidget(frm_line_top9_gd) # vbox3.addSpacing(20) # gradient ascent # btn_gradient_ascent = QPushButton("Find out what was learnt in this unit") # vbox3.addWidget(btn_gradient_ascent) # endregion hbox = QHBoxLayout() widget_vbox1 = QFrame() widget_vbox1.setLayout(vbox1) widget_vbox1.setFixedWidth(widget_vbox1.sizeHint().width()) widget_vbox2 = QFrame() widget_vbox2.setLayout(vbox2) widget_vbox3 = QFrame() widget_vbox3.setLayout(vbox3) widget_vbox3.setFixedWidth(widget_vbox3.sizeHint().width()) frm_line_1_2 = QFrame() frm_line_1_2.setFrameShape(QFrame.VLine) frm_line_1_2.setFrameShadow(QFrame.Sunken) frm_line_1_2.setLineWidth(2) frm_line_2_3 = QFrame() frm_line_2_3.setFrameShape(QFrame.VLine) frm_line_2_3.setFrameShadow(QFrame.Sunken) frm_line_2_3.setLineWidth(2) hbox.addWidget(widget_vbox1) hbox.addWidget(frm_line_1_2) hbox.addWidget(widget_vbox2) hbox.addWidget(frm_line_2_3) hbox.addWidget(widget_vbox3) central_widget = QWidget() central_widget.setLayout(hbox) self.statusbar = self.statusBar() self.statusbar.showMessage('ready') self.setCentralWidget(central_widget) self.setWindowTitle('CNN Visualizer') self.center() self.showMaximized()
class Genesis(QMainWindow): def __init__(self): super().__init__() self.setObjectName("Genesis") self.resize(814, 600) font = QFont() font.setFamily("Cascadia Code PL") font.setPointSize(16) self.setFont(font) self.contenedor = QWidget(self) self.contenedor.setObjectName("contenedor") self.grid_central = QGridLayout(self.contenedor) self.grid_central.setObjectName("grid_central") self.marco = QFrame(self.contenedor) self.marco.setStyleSheet("background-color: teal;") self.marco.setFrameShape(QFrame.Panel) self.marco.setFrameShadow(QFrame.Sunken) self.marco.setObjectName("marco") self.grid = QGridLayout(self.marco) self.grid.setObjectName("grid") self.reproductor = QGridLayout() self.reproductor.setObjectName("reproductor") self.logo = QLabel(self.marco) self.logo.setMinimumSize(16777215, 16777215) self.logo.setMaximumSize(QSize(16777215, 16777215)) font = QFont() font.setPointSize(22) self.logo.setFont(font) self.logo.setFrameShape(QFrame.StyledPanel) self.logo.setPixmap(QPixmap(":/img/genesis.jpg")) self.logo.setScaledContents(True) self.logo.setAlignment(Qt.AlignCenter) self.logo.setObjectName("logo") self.reproductor.addWidget(self.logo, 0, 0, 1, 1) self.grid.addLayout(self.reproductor, 0, 0, 1, 1) self.grid_central.addWidget(self.marco, 1, 0, 1, 1) self.lista = QListView(self.contenedor) self.lista.setMinimumSize(QSize(300, 16777215)) self.lista.setMaximumSize(QSize(300, 16777215)) self.lista.setStyleSheet("color: rgb(255, 255, 255);\n" "background-color: darkred;") self.lista.setObjectName("lista") self.grid_central.addWidget(self.lista, 1, 1, 1, 1) self.box_controles = QGroupBox(self.contenedor) self.box_controles.setMaximumSize(QSize(16777215, 122)) self.box_controles.setObjectName("box_controles") self.grid_controles = QGridLayout(self.box_controles) self.grid_controles.setObjectName("grid_controles") self.parar = QPushButton(self.box_controles) self.parar.setMaximumSize(QSize(50, 109)) self.parar.setToolTip('Detener Reproduccion') icon = QIcon() icon.addPixmap(QPixmap(":/img/stop.svg"), QIcon.Normal, QIcon.Off) self.parar.setIcon(icon) self.parar.setIconSize(QSize(48, 29)) self.parar.setFlat(True) self.parar.setObjectName("parar") self.grid_controles.addWidget(self.parar, 0, 1, 1, 1) self.adelante = QPushButton(self.box_controles) self.adelante.setMaximumSize(QSize(50, 109)) self.adelante.setToolTip('Adelantar a la siguiente cancion') icon1 = QIcon() icon1.addPixmap(QPixmap(":/img/next.svg"), QIcon.Normal, QIcon.Off) self.adelante.setIcon(icon1) self.adelante.setIconSize(QSize(48, 29)) self.adelante.setFlat(True) self.adelante.setObjectName("adelante") self.grid_controles.addWidget(self.adelante, 0, 3, 1, 1) self.reproducir = QPushButton(self.box_controles) self.reproducir.setMaximumSize(QtCore.QSize(50, 109)) icon2 = QIcon() icon2.addPixmap(QPixmap(":/img/play.svg"), QIcon.Normal, QIcon.Off) self.reproducir.setIcon(icon2) self.reproducir.setIconSize(QSize(48, 29)) self.reproducir.setFlat(True) self.reproducir.setObjectName("reproducir") self.grid_controles.addWidget(self.reproducir, 0, 0, 1, 1) self.cargar = QPushButton(self.box_controles) self.cargar.setMaximumSize(QSize(50, 109)) self.cargar.setToolTip('Cargar archivo') icon3 = QIcon() icon3.addPixmap(QPixmap(":/img/eject-1.svg"), QIcon.Normal, QIcon.Off) self.cargar.setIcon(icon3) self.cargar.setIconSize(QSize(48, 29)) self.cargar.setFlat(True) self.cargar.setObjectName("cargar") self.grid_controles.addWidget(self.cargar, 0, 4, 1, 1) self.grid_sliders = QHBoxLayout() self.grid_sliders.setObjectName("grid_sliders") self.tiempo = QSlider(self.box_controles) self.tiempo.setOrientation(Qt.Horizontal) self.tiempo.setObjectName("tiempo") self.grid_sliders.addWidget(self.tiempo) self.logo_volumen = QPushButton(self.box_controles) self.logo_volumen.setMaximumSize(QSize(41, 41)) icon4 = QIcon() icon4.addPixmap(QPixmap(":/img/altavoz3.png"), QIcon.Normal, QIcon.Off) self.logo_volumen.setIcon(icon4) self.logo_volumen.setIconSize(QSize(25, 25)) self.logo_volumen.setFlat(True) self.logo_volumen.setObjectName("logo_volumen") self.grid_sliders.addWidget(self.logo_volumen) self.volumen = QSlider(self.box_controles) self.volumen.setMaximumSize(QSize(139, 16777215)) self.volumen.setPageStep(1) self.volumen.setOrientation(Qt.Horizontal) self.volumen.setObjectName("volumen") self.grid_sliders.addWidget(self.volumen) self.grid_controles.addLayout(self.grid_sliders, 1, 0, 1, 7) self.atras = QPushButton(self.box_controles) self.atras.setMaximumSize(QSize(50, 109)) self.atras.setToolTip('Atrasar a la anterior cancion') icon5 = QIcon() icon5.addPixmap(QPixmap(":/img/back.svg"), QIcon.Normal, QIcon.Off) self.atras.setIcon(icon5) self.atras.setIconSize(QSize(48, 29)) self.atras.setFlat(True) self.atras.setObjectName("atras") self.grid_controles.addWidget(self.atras, 0, 2, 1, 1) self.menu = QPushButton(self.box_controles) self.menu.setMaximumSize(QSize(50, 109)) self.menu.setToolTip('Ocultar la lista de reproduccion') icon6 = QIcon() icon6.addPixmap(QPixmap(":/img/menu2.png"), QIcon.Normal, QIcon.Off) self.menu.setIcon(icon6) self.menu.setIconSize(QSize(48, 29)) self.menu.setFlat(True) self.menu.setObjectName("menu") self.grid_controles.addWidget(self.menu, 0, 6, 1, 1) self.datos = QLabel(self.box_controles) self.datos.setMinimumSize(QSize(0, 0)) self.datos.setFrameShape(QFrame.StyledPanel) self.datos.setIndent(13) self.datos.setObjectName("datos") self.grid_controles.addWidget(self.datos, 0, 5, 1, 1) self.grid_central.addWidget(self.box_controles, 0, 0, 1, 2) self.setCentralWidget(self.contenedor) self.setWindowTitle(" Genesis Reproductor") self.setWindowIcon(QIcon('img/icono.jpg')) self.box_controles.setTitle(" Bienvenido ...") self.show()
def initUI(self): # exitAct = QAction(QIcon('exitpic.png'), ' &Exit', self) # exitAct.setShortcut('Ctrl+Q') # exitAct.setStatusTip('Exit application') # exitAct.triggered.connect(qApp.quit) # self.statusbar = self.statusBar() # self.statusbar.showMessage('Ready') # menubar = self.menuBar() # fileMenu = menubar.addMenu(' &File') # fileMenu.addAction(exitAct) # impMenu = QMenu('Import', self) # impAct = QAction('Import mail', self) # impMenu.addAction(impAct) # newAct = QAction('New', self) # fileMenu.addAction(newAct) # fileMenu.addMenu(impMenu) # viewMenu = menubar.addMenu('View') # viewStatAct = QAction('View statusbar', self, checkable=True) # viewStatAct.setStatusTip('View statusbar') # viewStatAct.setChecked(True) # viewStatAct.triggered.connect(self.toggleMenu) # viewMenu.addAction(viewStatAct) # self.setGeometry(300, 300, 250, 150) # self.setWindowTitle('Statusbar') # self.show() hbox = QHBoxLayout(self) topleft = QFrame(self) topleft.setFrameShape(QFrame.StyledPanel) topright = QFrame(self) topright.setFrameShape(QFrame.StyledPanel) bottom = QFrame(self) bottom.setFrameShape(QFrame.StyledPanel) okButton = QPushButton("OK") cancelButton = QPushButton("Cancel") topright.addWidget(okButton) topleft.addWidget(cancelButton) splitter1 = QSplitter(Qt.Horizontal) splitter1.addWidget(topleft) splitter1.addWidget(topright) splitter2 = QSplitter(Qt.Vertical) splitter2.addWidget(splitter1) splitter2.addWidget(bottom) hbox.addWidget(splitter2) # okButton = QPushButton("OK") # cancelButton = QPushButton("Cancel") # hbox = QHBoxLayout() # hbox.addStretch(1) # hbox.addWidget(okButton) # hbox.addWidget(cancelButton) # vbox = QVBoxLayout() # vbox.addStretch(1) # vbox.addLayout(hbox) # self.setLayout(vbox) # self.setGeometry(300, 300, 300, 150) # self.setWindowTitle('Buttons') # self.show() self.setLayout(hbox) self.setGeometry(300, 300, 300, 200) self.setWindowTitle('QSplitter') self.show()
class Ui_MainWindow(QMainWindow): def __init__(self): super(Ui_MainWindow, self).__init__() self.setWindowIcon(QIcon('icon.ico')) self.setFixedSize(531, 470) def setupUi(self): self.centralwidget = QWidget(self) with open("style.css", 'r') as file: self.centralwidget.setStyleSheet(file.read()) self.appswidget = QWidget(self.centralwidget) self.appswidget.setGeometry(50, 0, 481, 470) self.appswidget.setProperty('class', 'appswidget') self.sidebar = QFrame(self) self.sidebar.setFrameShape(QFrame.StyledPanel) self.sidebar.setGeometry(0, 0, 50, 470) self.sidebar.setProperty('class', 'sidebar') self.refresh_btn = QPushButton(self.sidebar) self.refresh_btn.setGeometry(QRect(0, 0, 51, 51)) self.refresh_btn.setProperty('class', 'sidebar_btns') self.refresh_btn.setIcon(QIcon(':/icon/refresh_icon.png')) self.refresh_btn.setIconSize(QSize(24, 24)) self.refresh_bind = QShortcut(QKeySequence('Ctrl+R'), self) self.store_btn = QPushButton(self.sidebar) self.store_btn.setGeometry(QRect(0, 51, 51, 51)) self.store_btn.setProperty('class', 'sidebar_btns') self.store_btn.setIcon(QIcon(':/icon/store_icon.png')) self.store_btn.setIconSize(QSize(24, 24)) self.store_bind = QShortcut(QKeySequence('Ctrl+S'), self) self.homepage_btn = QPushButton(self.sidebar) self.homepage_btn.setGeometry(QRect(0, 102, 51, 51)) self.homepage_btn.setProperty('class', 'sidebar_btns') self.homepage_btn.setIcon(QIcon(':/icon/github_icon.png')) self.homepage_btn.setIconSize(QSize(24, 24)) self.homepage_bind = QShortcut(QKeySequence('Ctrl+G'), self) self.about_btn = QPushButton(self.sidebar) self.about_btn.setGeometry(QRect(0, 153, 51, 51)) self.about_btn.setProperty('class', 'sidebar_btns') self.about_btn.setIcon(QIcon(':/icon/about_icon.png')) self.about_btn.setIconSize(QSize(24, 24)) self.about_bind = QShortcut(QKeySequence('Ctrl+A'), self) self.quit_btn = QPushButton(self.sidebar) self.quit_btn.setGeometry(QRect(0, 420, 51, 51)) self.quit_btn.setProperty('class', 'sidebar_btns_quit') self.quit_btn.setIcon(QIcon(':/icon/quit_icon.png')) self.quit_btn.setIconSize(QSize(24, 24)) self.quit_bind = QShortcut(QKeySequence('Ctrl+Q'), self) self.font = QFont() self.font.setPointSize(8) self.font.setStyleStrategy(QFont.PreferAntialias) self.label_refresh = QLabel(self.appswidget) self.label_refresh.setFont(self.font) self.label_refresh.setGeometry(QRect(20, 10, 441, 15)) self.label_info = QLabel(self.appswidget) self.label_info.setFont(self.font) self.label_info.setGeometry(QRect(20, 15, 441, 30)) self.progressbar = QProgressBar(self.appswidget) self.progressbar.setGeometry(QRect(20, 35, 441, 20)) self.verticalLayoutWidget = QWidget(self.appswidget) self.verticalLayoutWidget.setGeometry(QRect(20, 55, 121, 311)) self.verticalLayout = QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.checkBox = QCheckBox(self.verticalLayoutWidget) self.checkBox_2 = QCheckBox(self.verticalLayoutWidget) self.checkBox_3 = QCheckBox(self.verticalLayoutWidget) self.checkBox_4 = QCheckBox(self.verticalLayoutWidget) self.checkBox_5 = QCheckBox(self.verticalLayoutWidget) self.checkBox_6 = QCheckBox(self.verticalLayoutWidget) self.checkBox_7 = QCheckBox(self.verticalLayoutWidget) self.checkBox_8 = QCheckBox(self.verticalLayoutWidget) self.checkBox_9 = QCheckBox(self.verticalLayoutWidget) self.checkBox_10 = QCheckBox(self.verticalLayoutWidget) self.checkBox_11 = QCheckBox(self.verticalLayoutWidget) checkbox_column_1 = (self.checkBox, self.checkBox_2, self.checkBox_3, self.checkBox_4, self.checkBox_5, self.checkBox_6, self.checkBox_7, self.checkBox_8, self.checkBox_9, self.checkBox_10, self.checkBox_11) for checkbox in checkbox_column_1: self.verticalLayout.addWidget(checkbox) self.verticalLayoutWidget_2 = QWidget(self.appswidget) self.verticalLayoutWidget_2.setGeometry(QRect(170, 55, 131, 311)) self.verticalLayout_2 = QVBoxLayout(self.verticalLayoutWidget_2) self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.checkBox_12 = QCheckBox(self.verticalLayoutWidget_2) self.checkBox_13 = QCheckBox(self.verticalLayoutWidget_2) self.checkBox_14 = QCheckBox(self.verticalLayoutWidget_2) self.checkBox_15 = QCheckBox(self.verticalLayoutWidget_2) self.checkBox_16 = QCheckBox(self.verticalLayoutWidget_2) self.checkBox_17 = QCheckBox(self.verticalLayoutWidget_2) self.checkBox_18 = QCheckBox(self.verticalLayoutWidget_2) self.checkBox_19 = QCheckBox(self.verticalLayoutWidget_2) self.checkBox_20 = QCheckBox(self.verticalLayoutWidget_2) self.checkBox_21 = QCheckBox(self.verticalLayoutWidget_2) self.checkBox_22 = QCheckBox(self.verticalLayoutWidget_2) checkbox_column_2 = (self.checkBox_12, self.checkBox_13, self.checkBox_14, self.checkBox_15, self.checkBox_16, self.checkBox_17, self.checkBox_18, self.checkBox_19, self.checkBox_20, self.checkBox_21, self.checkBox_22) for checkbox in checkbox_column_2: self.verticalLayout_2.addWidget(checkbox) self.verticalLayoutWidget_3 = QWidget(self.appswidget) self.verticalLayoutWidget_3.setGeometry(QRect(330, 55, 131, 311)) self.verticalLayout_3 = QVBoxLayout(self.verticalLayoutWidget_3) self.verticalLayout_3.setContentsMargins(0, 0, 0, 0) self.checkBox_23 = QCheckBox(self.verticalLayoutWidget_3) self.checkBox_24 = QCheckBox(self.verticalLayoutWidget_3) self.checkBox_25 = QCheckBox(self.verticalLayoutWidget_3) self.checkBox_26 = QCheckBox(self.verticalLayoutWidget_3) self.checkBox_27 = QCheckBox(self.verticalLayoutWidget_3) self.checkBox_28 = QCheckBox(self.verticalLayoutWidget_3) self.checkBox_29 = QCheckBox(self.verticalLayoutWidget_3) self.checkBox_30 = QCheckBox(self.verticalLayoutWidget_3) self.checkBox_31 = QCheckBox(self.verticalLayoutWidget_3) self.checkBox_32 = QCheckBox(self.verticalLayoutWidget_3) self.checkBox_33 = QCheckBox(self.verticalLayoutWidget_3) checkbox_column_3 = (self.checkBox_23, self.checkBox_24, self.checkBox_25, self.checkBox_26, self.checkBox_27, self.checkBox_28, self.checkBox_29, self.checkBox_30, self.checkBox_31, self.checkBox_32, self.checkBox_33) for checkbox in checkbox_column_3: self.verticalLayout_3.addWidget(checkbox) self.label_note = QLabel(self.appswidget) self.label_note.setFont(self.font) self.label_note.setGeometry(QRect(20, 370, 350, 16)) self.label_space = QLabel(self.appswidget) self.label_space.setFont(self.font) self.label_space.setGeometry(QRect(20, 390, 350, 16)) self.label_size = QLabel(self.appswidget) self.label_size.setFont(self.font) self.label_size.setGeometry(QRect(155, 390, 200, 16)) self.horizontalLayoutWidget_2 = QWidget(self.appswidget) self.horizontalLayoutWidget_2.setGeometry(QRect(20, 420, 220, 31)) self.horizontalLayout_2 = QHBoxLayout(self.horizontalLayoutWidget_2) self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.button_select_all = QPushButton(self.horizontalLayoutWidget_2) self.button_select_all.setIcon(QIcon(':/icon/no_check_icon.png')) self.button_select_all.setIconSize(QSize(18, 18)) self.button_select_all.setLayoutDirection(Qt.RightToLeft) self.horizontalLayout_2.addWidget(self.button_select_all) self.button_select_all.setMinimumSize(100, 30) self.button_select_all.setProperty('class', 'Aqua') self.button_deselect_all = QPushButton(self.horizontalLayoutWidget_2) self.button_deselect_all.setIcon(QIcon(':/icon/no_cancel_icon.png')) self.button_deselect_all.setIconSize(QSize(18, 18)) self.button_deselect_all.setLayoutDirection(Qt.RightToLeft) self.horizontalLayout_2.addWidget(self.button_deselect_all) self.button_deselect_all.setMinimumSize(100, 30) self.button_deselect_all.setProperty('class', 'Aqua') self.horizontalLayoutWidget = QWidget(self.appswidget) self.horizontalLayoutWidget.setGeometry(QRect(354, 420, 107, 31)) self.horizontalLayout = QHBoxLayout(self.horizontalLayoutWidget) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.button_uninstall = QPushButton(self.horizontalLayoutWidget) self.button_uninstall.setIcon(QIcon(':/icon/no_trash_icon.png')) self.button_uninstall.setIconSize(QSize(18, 18)) self.button_uninstall.setLayoutDirection(Qt.RightToLeft) self.horizontalLayout.addWidget(self.button_uninstall) self.button_uninstall.setMinimumSize(100, 30) self.button_uninstall.setProperty('class', 'Grapefruit') with open("style.css", 'r') as file: widgets = (self.sidebar, self.refresh_btn, self.homepage_btn, self.about_btn, self.quit_btn, self.progressbar, self.button_select_all, self.button_deselect_all, self.button_uninstall) for widget in widgets: widget.setStyleSheet(file.read()) self.setCentralWidget(self.centralwidget) self.retranslateUi() QMetaObject.connectSlotsByName(self) def retranslateUi(self): _translate = QCoreApplication.translate self.setWindowTitle(_translate("MainWindow", "PyDebloatX")) self.label_info.setText( _translate("MainWindow", "Refreshing list of installed apps...")) self.checkBox.setText(_translate("MainWindow", "3D Builder")) self.checkBox_2.setText(_translate("MainWindow", "3D Viewer")) self.checkBox_3.setText(_translate("MainWindow", "Alarms and Clock")) self.checkBox_4.setText(_translate("MainWindow", "Calculator")) self.checkBox_5.setText(_translate("MainWindow", "Calendar and Mail")) self.checkBox_6.setText(_translate("MainWindow", "Camera")) self.checkBox_7.setText(_translate("MainWindow", "Get Help")) self.checkBox_8.setText(_translate("MainWindow", "Groove Music")) self.checkBox_9.setText(_translate("MainWindow", "Maps")) self.checkBox_10.setText(_translate("MainWindow", "Messaging")) self.checkBox_11.setText( _translate("MainWindow", "Mixed Reality Portal")) self.checkBox_12.setText(_translate("MainWindow", "Mobile Plans")) self.checkBox_13.setText(_translate("MainWindow", "Money")) self.checkBox_14.setText(_translate("MainWindow", "Movies && TV")) self.checkBox_15.setText(_translate("MainWindow", "News")) self.checkBox_16.setText(_translate("MainWindow", "Office")) self.checkBox_17.setText(_translate("MainWindow", "OneNote")) self.checkBox_18.setText(_translate("MainWindow", "Paint 3D")) self.checkBox_19.setText(_translate("MainWindow", "People")) self.checkBox_20.setText(_translate("MainWindow", "Photos")) self.checkBox_21.setText(_translate("MainWindow", "Skype")) self.checkBox_22.setText(_translate("MainWindow", "Snip && Sketch")) self.checkBox_23.setText(_translate("MainWindow", "Solitaire")) self.checkBox_24.setText(_translate("MainWindow", "Sports")) self.checkBox_25.setText(_translate("MainWindow", "Spotify")) self.checkBox_26.setText(_translate("MainWindow", "Sticky Notes")) self.checkBox_27.setText(_translate("MainWindow", "Tips")) self.checkBox_28.setText(_translate("MainWindow", "Voice Recorder")) self.checkBox_29.setText(_translate("MainWindow", "Weather")) self.checkBox_30.setText(_translate("MainWindow", "Windows Feedback")) self.checkBox_31.setText(_translate("MainWindow", "Xbox")) self.checkBox_32.setText(_translate("MainWindow", "Xbox Game Bar")) self.checkBox_33.setText(_translate("MainWindow", "Your Phone")) self.label_note.setText( _translate( "MainWindow", "NOTE: Microsoft Edge and Cortana cannot be uninstalled using this GUI." )) self.label_space.setText( _translate("MainWindow", "Total amount of disk space:")) self.label_size.setText(_translate("MainWindow", "0 MB")) self.button_select_all.setText(_translate("MainWindow", "Select All")) self.button_deselect_all.setText( _translate("MainWindow", "Deselect All")) self.button_uninstall.setText(_translate("MainWindow", "Uninstall")) QToolTip.setFont(self.font) self.checkBox.setToolTip('View, create, and personalize 3D objects.') self.checkBox_2.setToolTip( 'View 3D models and animations in real-time.') self.checkBox_3.setToolTip( 'A combination of alarm clock, world clock, timer, and stopwatch.') self.checkBox_4.setToolTip( 'A calculator that includes standard, scientific, and programmer modes, as well as a unit converter.' ) self.checkBox_5.setToolTip( 'Stay up to date with email and schedule managing.') self.checkBox_6.setToolTip( 'Point and shoot to take pictures on Windows 10.') self.checkBox_7.setToolTip( 'Provide a way to ask a question and get recommended solutions or contact assisted support.' ) self.checkBox_8.setToolTip( 'Listen to music on Windows, iOS, and Android devices.') self.checkBox_9.setToolTip( 'Search for places to get directions, business info, and reviews.') self.checkBox_10.setToolTip( 'Quick, reliable SMS, MMS and RCS messaging from your phone.') self.checkBox_11.setToolTip( 'Discover Windows Mixed Reality and dive into more than 3,000 games and VR experiences from Steam®VR and Microsoft Store.' ) self.checkBox_12.setToolTip( 'Sign up for a data plan and connect with mobile operators in your area. You will need a supported SIM card.' ) self.checkBox_13.setToolTip( 'Finance calculators, currency exchange rates and commodity prices from around the world.' ) self.checkBox_14.setToolTip( 'All your movies and TV shows, all in one place, on all your devices.' ) self.checkBox_15.setToolTip( 'Deliver breaking news and trusted, in-depth reporting from the world\'s best journalists.' ) self.checkBox_16.setToolTip( 'Find all your Office apps and files in one place.') self.checkBox_17.setToolTip( 'Digital notebook for capturing and organizing everything across your devices.' ) self.checkBox_18.setToolTip( 'Make 2D masterpieces or 3D models that you can play with from all angles.' ) self.checkBox_19.setToolTip( 'Connect with all your friends, family, colleagues, and acquaintances in one place.' ) self.checkBox_20.setToolTip( 'View and edit your photos and videos, make movies, and create albums.' ) self.checkBox_21.setToolTip( 'Instant message, voice or video call application.') self.checkBox_22.setToolTip( 'Quickly annotate screenshots, photos and other images and save, paste or share with other apps.' ) self.checkBox_23.setToolTip( 'Solitaire is one of the most played computer card games of all time.' ) self.checkBox_24.setToolTip( 'Live scores and in-depth game experiences for more than 150 leagues.' ) self.checkBox_25.setToolTip( 'Play your favorite songs and albums free on Windows 10 with Spotify.' ) self.checkBox_26.setToolTip( 'Create notes, type, ink or add a picture, add text formatting, or stick them to the desktop.' ) self.checkBox_27.setToolTip( 'Provide users with information and tips about operating system features.' ) self.checkBox_28.setToolTip( 'Record sounds, lectures, interviews, and other events.') self.checkBox_29.setToolTip( 'Latest weather conditions, accurate 10-day and hourly forecasts.') self.checkBox_30.setToolTip( 'Provide feedback about Windows and apps by sharing suggestions or problems.' ) self.checkBox_31.setToolTip( 'Browse the catalogue, view recommendations, and discover PC games with Xbox Game Pass.' ) self.checkBox_32.setToolTip( 'Instant access to widgets for screen capture and sharing, and chatting with Xbox friends.' ) self.checkBox_33.setToolTip( 'Link your Android phone and PC to view and reply to text messages, access mobile apps, and receive notifications.' )
def initUI(self): centerFrame = QFrame(self) centerFrame.setFrameShape(QFrame.WinPanel) user = QLabel('账号: ') pwd = QLabel('密码: ') cpwd = QLabel('确认:') self.userInput = QLineEdit() self.userInput.setPlaceholderText('请输入学号') self.pwdInput = QLineEdit() self.pwdInput.setPlaceholderText('请输入密码') self.pwdInput.setEchoMode(QLineEdit.Password) #密码不以明文显示 self.cpwdInput = QLineEdit() self.cpwdInput.setPlaceholderText('请输入密码') self.cpwdInput.setEchoMode(QLineEdit.Password) self.registerButton = QPushButton('注册', self) self.registerButton.setIcon(QIcon('./image/sgin.png')) self.registerButton.clicked.connect(self.onRegister) self.loginButton = QPushButton('登录', self) self.loginButton.setFont(QFont('黑体')) # self.loginButton.setStyleSheet("border:2px; border-radius:10px; background-color:rgba(0,0,255,200)") self.loginButton.setIcon(QIcon('./image/login.png')) self.loginButton.clicked.connect(self.onLogin) formlayout = QFormLayout() formlayout.addRow(user, self.userInput) formlayout.addRow(pwd, self.pwdInput) formlayout.addRow(cpwd, self.cpwdInput) self.stubtn = QRadioButton('学生') self.teabtn = QRadioButton('教师') rhbox = QHBoxLayout() rhbox.addStretch(1) rhbox.addWidget(self.stubtn) rhbox.addWidget(self.teabtn) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self.registerButton) hbox.addStretch(1) vbox = QVBoxLayout() vbox.addLayout(formlayout) vbox.addLayout(rhbox) vbox.addLayout(hbox) vbox.setStretchFactor(formlayout, 5) centerFrame.setLayout(vbox) hbox1 = QHBoxLayout() hbox1.addStretch(1) hbox1.addStretch(1) hbox1.addWidget(self.loginButton) vbox1 = QVBoxLayout() vbox1.addWidget(centerFrame) vbox1.addLayout(hbox1) self.setLayout(vbox1) self.resize(350, 250) # 设置窗口大小 center(self) # 使得串口显示在屏幕中央 self.setFont(QFont("宋体", 11)) self.setWindowTitle('账号注册') self.setWindowIcon(QIcon('./image/sgin.png'))
def __init__(self): super().__init__() self.IsBusy = False self.IsUpdating = False self.currentSelectedTabIndex = 0 self.setWindowTitle("TOR") self.setWindowIcon(TORIcons.APP_ICON) self.cdvs = [] self.cds = [] clients = DBManager.getAllClients() layClientDetails = QHBoxLayout() layClientDetails.setContentsMargins(0, 0, 0, 0) grpClientDetailsRegions = [QGroupBox() for i in range(3)] for g in grpClientDetailsRegions: g.setObjectName("ClientGroup") grpClientDetailsRegions[0].setTitle("Front") grpClientDetailsRegions[1].setTitle("Middle") grpClientDetailsRegions[2].setTitle("Back") layClientDetailsRegions = [QGridLayout() for i in range(3)] for i in range(3): #layClientDetailsRegions[i].setContentsMargins(0, 0, 0, 0) #layClientDetailsRegions[i].setSpacing(0) grpClientDetailsRegions[i].setLayout(layClientDetailsRegions[i]) #grpClientDetailsRegions[i].setContentsMargins(0, 0, 0, 0) for j in range(3): for k in range(3): c = clients[i*9 + j*3 + k] cdv = ClientDetailView() cd = ClientDetails() cd.Id = c.Id cd.IP = c.IP cd.Material = c.Material cd.Position = c.Position cd.Latin = c.Latin cd.AllowUserMode = c.AllowUserMode cd.IsActive = c.IsActive cdv.clientDetails = cd cdv.grpMainGroup.setTitle("#{}: {}...".format(cd.Position, cd.Latin[0:9])) layClientDetailsRegions[i].addWidget(cdv, k, 3*i + j) self.cdvs.append(cdv) self.cds.append(cd) layClientDetails.addWidget(grpClientDetailsRegions[i]) wdgClientDetails = QWidget() wdgClientDetails.setLayout(layClientDetails) self.btnStartAllTORPrograms = QPushButton() self.btnStartAllTORPrograms.setText("START installation") self.btnStartAllTORPrograms.clicked.connect(self.btnStartAllTORPrograms_clicked) self.btnStartAllTORPrograms.setStyleSheet("QPushButton { font-weight: bold }; ") self.btnStopAllTORPrograms = QPushButton() self.btnStopAllTORPrograms.setText("STOP installation") self.btnStopAllTORPrograms.clicked.connect(self.btnStopAllTORPrograms_clicked) self.btnStopAllTORPrograms.setStyleSheet("QPushButton { font-weight: bold }; ") self.btnStartAllClientService = QPushButton() self.btnStartAllClientService.setText("Start all active TORClients") self.btnStartAllClientService.clicked.connect(self.btnStartAllClientService_clicked) self.btnStopAllClientService = QPushButton() self.btnStopAllClientService.setText("Stop all TORClients") self.btnStopAllClientService.clicked.connect(self.btnStopAllClientService_clicked) self.btnSaveSettings = QPushButton() self.btnSaveSettings.setText("Save Settings") self.btnSaveSettings.clicked.connect(self.btnSaveSettings_clicked) self.btnRestoreSettings = QPushButton() self.btnRestoreSettings.setText("Restore Settings") self.btnRestoreSettings.clicked.connect(self.btnRestoreSettings_clicked) self.btnStartTORServer = QPushButton() self.btnStartTORServer.setText("Start TOR Server") self.btnStartTORServer.clicked.connect(self.btnStartTORServer_clicked) self.btnStopTORServer = QPushButton() self.btnStopTORServer.setText("Stop TOR Server") self.btnStopTORServer.clicked.connect(self.btnStopTORServer_clicked) self.btnStartTORInteractive = QPushButton() self.btnStartTORInteractive.setText("Start Visitor App") self.btnStartTORInteractive.clicked.connect(self.btnStartTORInteractive_clicked) self.btnStopTORInteractive = QPushButton() self.btnStopTORInteractive.setText("Stop Visitor App") self.btnStopTORInteractive.clicked.connect(self.btnStopTORInteractive_clicked) self.btnEndAllUserModes = QPushButton() self.btnEndAllUserModes.setText("End all visitor control") self.btnEndAllUserModes.clicked.connect(self.btnEndAllUserModes_clicked) self.btnTurnOnLEDs = QPushButton() self.btnTurnOnLEDs.setText("Turn ON all LEDs") self.btnTurnOnLEDs.clicked.connect(self.btnTurnOnLEDs_clicked) self.btnTurnOffLEDs = QPushButton() self.btnTurnOffLEDs.setText("Turn OFF all LEDs") self.btnTurnOffLEDs.clicked.connect(self.btnTurnOffLEDs_clicked) self.btnUpdateDashboard = QPushButton() self.btnUpdateDashboard.setText("Update dashboard") self.btnUpdateDashboard.clicked.connect(self.btnUpdateDashboard_clicked) self.lblLastUpdateTime = QLabel() spacerSize = 30 layDashboardButtons = QVBoxLayout() layDashboardButtons.addSpacing(spacerSize) layDashboardButtons.addWidget(QLabel("<h3>Installation</h3>")) layDashboardButtons.addWidget(self.btnStartAllTORPrograms) layDashboardButtons.addWidget(self.btnStopAllTORPrograms) layDashboardButtons.addSpacing(spacerSize) layDashboardButtons.addWidget(QLabel("Clients")) layDashboardButtons.addWidget(self.btnStartAllClientService) layDashboardButtons.addWidget(self.btnStopAllClientService) layDashboardButtons.addSpacing(spacerSize) layDashboardButtons.addWidget(QLabel("LEDs")) layDashboardButtons.addWidget(self.btnTurnOnLEDs) layDashboardButtons.addWidget(self.btnTurnOffLEDs) layDashboardButtons.addSpacing(spacerSize) layDashboardButtons.addWidget(QLabel("Server")) layDashboardButtons.addWidget(self.btnStartTORServer) layDashboardButtons.addWidget(self.btnStopTORServer) layDashboardButtons.addSpacing(spacerSize) layDashboardButtons.addWidget(QLabel("Visitor App")) layDashboardButtons.addWidget(self.btnStartTORInteractive) layDashboardButtons.addWidget(self.btnStopTORInteractive) layDashboardButtons.addWidget(self.btnEndAllUserModes) layDashboardButtons.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) layDashboardButtons.addWidget(self.btnUpdateDashboard) layDashboardButtons.addWidget(self.lblLastUpdateTime) wdgDashboardButtons = QWidget() wdgDashboardButtons.setLayout(layDashboardButtons) """ layDashboardButtonsTop = QHBoxLayout() layDashboardButtonsTop.addWidget(self.btnStartAllClientService) layDashboardButtonsTop.addWidget(self.btnStopAllClientService) layDashboardButtonsTop.addWidget(self.btnSaveSettings) layDashboardButtonsTop.addWidget(self.btnRestoreSettings) wdgDashboardButtonsTop = QWidget() wdgDashboardButtonsTop.setLayout(layDashboardButtonsTop) layDashboardButtons2 = QHBoxLayout() layDashboardButtons2.addWidget(self.btnTurnOnLEDs) layDashboardButtons2.addWidget(self.btnTurnOffLEDs) wdgDashboardButtons2 = QWidget() wdgDashboardButtons2.setLayout(layDashboardButtons2) layDashboardButtonsBottom = QHBoxLayout() layDashboardButtonsBottom.addWidget(self.btnStartTORServer) layDashboardButtonsBottom.addWidget(self.btnStopTORServer) layDashboardButtonsBottom.addWidget(self.btnStartTORInteractive) layDashboardButtonsBottom.addWidget(self.btnStopTORInteractive) layDashboardButtonsBottom.addWidget(self.btnEndAllUserModes) wdgDashboardButtonsBottom = QWidget() wdgDashboardButtonsBottom.setLayout(layDashboardButtonsBottom) """ layDashboard = QHBoxLayout() #layDashboard.addWidget(wdgDashboardButtonsTop) #layDashboard.addWidget(wdgDashboardButtons2) layDashboard.addWidget(wdgClientDetails) #layDashboard.addWidget(wdgDashboardButtonsBottom) layDashboard.addWidget(wdgDashboardButtons) wdgDashboard = QWidget() wdgDashboard.setLayout(layDashboard) programNames = DBManager.getAllJobProgramNames() self.jobProgramNames = [pn.Name for pn in programNames] self.cmbTour = QComboBox() self.cmbTour.insertItem(-1, NEW_PROGRAM_NAME) for i in range(len(self.jobProgramNames)): self.cmbTour.insertItem(i, self.jobProgramNames[i]) self.cmbTour.currentIndexChanged.connect(self.cmbTour_currentIndexChanged) self.btnStartTour = QPushButton("Start") self.btnStartTour.clicked.connect(self.btnStartTour_clicked) self.btnEditTour = QPushButton("Edit") self.btnEditTour.clicked.connect(self.btnEditTour_clicked) layTourSelection = QHBoxLayout() layTourSelection.addWidget(QLabel("Program: ")) layTourSelection.addWidget(self.cmbTour) layTourSelection.addSpacing(100) layTourSelection.addWidget(self.btnStartTour) layTourSelection.addWidget(self.btnEditTour) layTourSelection.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) wdgTourSelection = QWidget() wdgTourSelection.setLayout(layTourSelection) self.jobListWidgets = [] layJobList = QGridLayout() jobs = DBManager.getCurrentJobs() layJobList.addWidget(QLabel("<h3>Box</h3>"), 0, 0) layJobList.addWidget(QLabel("<h3>Quit</h3>"), 0, 1) layJobList.addWidget(QLabel("<h3>Wait</h3>"), 0, 2) layJobList.addWidget(QLabel("<h3>Run</h3>"), 0, 3) layJobList.addWidget(QLabel("<h3>Run & Wait</h3>"), 0, 4) layJobList.addWidget(QLabel("<h3>Parameters</h3>"), 0, 5) chkQuitAll = QCheckBox() chkQuitAll.clicked.connect(self.chkQuitAll_clicked) chkWaitAll = QCheckBox() chkWaitAll.clicked.connect(self.chkWaitAll_clicked) chkRunAll = QCheckBox() chkRunAll.clicked.connect(self.chkRunAll_clicked) chkRunAndWaitAll = QCheckBox() chkAllGroup = QButtonGroup(self) chkAllGroup.addButton(chkQuitAll) chkAllGroup.addButton(chkWaitAll) chkAllGroup.addButton(chkRunAll) chkAllGroup.addButton(chkRunAndWaitAll) chkRunAndWaitAll.clicked.connect(self.chkRunAndWaitAll_clicked) txtParametersAll = QLineEdit() txtParametersAll.textChanged.connect(self.txtParametersAll_textChanged) layJobList.addWidget(chkQuitAll, 1, 1) layJobList.addWidget(chkWaitAll, 1, 2) layJobList.addWidget(chkRunAll, 1, 3) layJobList.addWidget(chkRunAndWaitAll, 1, 4) layJobList.addWidget(txtParametersAll, 1, 5) row = 2 clientCount = 0 for c in self.cds: chkQuit = QCheckBox() chkWait = QCheckBox() chkRun = QCheckBox() chkRunAndWait = QCheckBox() txtParameters = QLineEdit() chkGroup = QButtonGroup(self) chkGroup.addButton(chkQuit) chkGroup.addButton(chkWait) chkGroup.addButton(chkRun) chkGroup.addButton(chkRunAndWait) layJobList.addWidget(QLabel("Pos {}: {}".format(c.Position, c.Latin)), row, 0) layJobList.addWidget(chkQuit, row, 1) layJobList.addWidget(chkWait, row, 2) layJobList.addWidget(chkRun, row, 3) layJobList.addWidget(chkRunAndWait, row, 4) layJobList.addWidget(txtParameters, row, 5) self.jobListWidgets.append([c.Id, chkQuit, chkWait, chkRun, chkRunAndWait, txtParameters]) row += 1 clientCount += 1 if clientCount % 9 == 0 and clientCount < 27: line = QFrame() line.setGeometry(QRect()) line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layJobList.addWidget(line, row, 0, 1, 6) row += 1 self.fillJobList(jobs) self.wdgJobList = QWidget() self.wdgJobList.setEnabled(False) self.wdgJobList.setLayout(layJobList) lblJobDescriptionText = QLabel( """ The parameters for Job 'W' are of the form 't' where 't' is optional<br>check every t seconds if there is another job to do <br><br><br> The parameters for Job 'RW' are of the form 'r w t'<br>run r times, then wait w times for t seconds """) lblJobDescriptionText.setAlignment(Qt.AlignTop) layJobListAndDescriptions = QHBoxLayout() layJobListAndDescriptions.addWidget(self.wdgJobList) layJobListAndDescriptions.addSpacing(100) layJobListAndDescriptions.addWidget(lblJobDescriptionText) layJobListAndDescriptions.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) wdgJobListAndDescriptions = QWidget() wdgJobListAndDescriptions.setLayout(layJobListAndDescriptions) layJobOverview = QVBoxLayout() #layJobOverview.addWidget(QLabel("Job Overview")) layJobOverview.addWidget(wdgTourSelection) layJobOverview.addWidget(wdgJobListAndDescriptions) wdgJobOverivew = QWidget() wdgJobOverivew.setLayout(layJobOverview) # Client Details self.cmbClient = QComboBox() self.cmbClient.setFixedWidth(180) self.cmbClient.insertItem(-1, "All", -1) for c in self.cds: self.cmbClient.insertItem(c.Position, "#{}: {}".format(c.Position, c.Latin), c.Position) self.cmbClient.currentIndexChanged.connect(self.cmbClient_currentIndexChanged) self.btnRereshClientDetails = QPushButton("Refresh") self.btnRereshClientDetails.clicked.connect(self.btnRereshClientDetails_clicked) layClientSelection = QHBoxLayout() layClientSelection.addWidget(QLabel("Box: ")) layClientSelection.addWidget(self.cmbClient) layClientSelection.addSpacing(100) layClientSelection.addWidget(self.btnRereshClientDetails) layClientSelection.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) wdgClientSelection = QWidget() wdgClientSelection.setLayout(layClientSelection) self.tblResults = QTableView() self.tblResults.horizontalHeader().setStretchLastSection(True) self.tblResults.setWordWrap(False) self.tblResults.setTextElideMode(Qt.ElideRight) self.clientDetailInfoList = [ ["Name", QLabel("-")], ["Position", QLabel("-")], ["ID", QLabel("-")], ["IP", QLabel("-")], ["MAC", QLabel("-")], ["Allow User Mode", QLabel("-")], ["User Mode Active", QLabel("-")], ["Is Active", QLabel("-")], ["Current State", QLabel("-")], ["Current Job", QLabel("-")], ["Recent results", QLabel("-")], ["Average contribution", QLabel("-")], ["Average result (3.5)", QLabel("-")], ["Results last hour", QLabel("-")], ["Results last 2 hours", QLabel("-")], ["Results today", QLabel("-")], ["Results Total", QLabel("-")] ] layClientDetailInfos = QGridLayout() for num, (text, widget) in enumerate(self.clientDetailInfoList): layClientDetailInfos.addWidget(QLabel(text), num, 0) layClientDetailInfos.addWidget(widget, num, 1) grpClientDetailInfos = QGroupBox() grpClientDetailInfos.setTitle("Details") grpClientDetailInfos.setLayout(layClientDetailInfos) layClientDetailsTop = QHBoxLayout() layClientDetailsTop.addWidget(self.tblResults) layClientDetailsTop.addSpacing(100) layClientDetailsTop.addWidget(grpClientDetailInfos) layClientDetailsTop.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) wdgClientDetailsTop = QWidget() wdgClientDetailsTop.setLayout(layClientDetailsTop) self.tblLogMessages = QTableView() self.tblLogMessages.horizontalHeader().setStretchLastSection(True) self.tblLogMessages.setWordWrap(False) self.tblLogMessages.setTextElideMode(Qt.ElideRight) self.tblResultStatistics = QTableView() #self.tblResultStatistics.horizontalHeader().setStretchLastSection(True) self.tblResultStatistics.setWordWrap(False) self.tblResultStatistics.setTextElideMode(Qt.ElideRight) self.tblResultStatistics.setSortingEnabled(True) layClientDetailsBottom = QHBoxLayout() layClientDetailsBottom.addWidget(self.tblLogMessages) layClientDetailsBottom.addSpacing(20) layClientDetailsBottom.addWidget(self.tblResultStatistics) #layClientDetailsBottom.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) wdgClientDetailsBottom = QWidget() wdgClientDetailsBottom.setLayout(layClientDetailsBottom) layDetails = QVBoxLayout() layDetails.addWidget(wdgClientSelection) layDetails.addWidget(QLabel("Results")) layDetails.addWidget(wdgClientDetailsTop) layDetails.addWidget(QLabel("Log messages")) layDetails.addWidget(wdgClientDetailsBottom) wdgDetails = QWidget() wdgDetails.setLayout(layDetails) layTORServer = QVBoxLayout() layTORServer.addWidget(QLabel("TOR server")) wdgTORServer = QWidget() wdgTORServer.setLayout(layTORServer) self.clientDetailsTabIndex = 2 self.tabDashboard = QTabWidget() self.tabDashboard.addTab(wdgDashboard, "Dashboard") #self.tabDashboard.addTab(wdgTORServer, "TORServer") self.tabDashboard.addTab(wdgJobOverivew, "Jobs") self.tabDashboard.addTab(wdgDetails, "Detail View") self.dashboardTabIndex = 0 self.tabDashboard.currentChanged.connect(self.tabDashboard_currentChanged) self.txtStatus = QPlainTextEdit() self.txtStatus.setReadOnly(True) layMain = QVBoxLayout() layMain.addWidget(self.tabDashboard) layMain.addWidget(self.txtStatus) wdgMain = QWidget() wdgMain.setLayout(layMain) self.setCentralWidget(wdgMain) self.initDashboard() self.updateDashboard() timerFetchData = QTimer(self) timerFetchData.timeout.connect(self.updateDashboardFromTimer) timerFetchData.start(120 * 1000)
def __init__(self, *args): super().__init__(BrickletIndustrialDual020mA, *args) self.dual020 = self.device self.str_connected = 'Sensor {0} is <font color="green">connected (>= 3.9 mA)</font>' self.str_not_connected = 'Sensor {0} is <font color="red">not connected (< 3.9 mA)</font>' self.cbe_current0 = CallbackEmulator( self, self.dual020.get_current, 0, self.cb_current, self.increase_error_count, pass_arguments_to_result_callback=True) self.cbe_current1 = CallbackEmulator( self, self.dual020.get_current, 1, self.cb_current, self.increase_error_count, pass_arguments_to_result_callback=True) self.connected_labels = [ FixedSizeLabel(self.str_not_connected.format(0)), FixedSizeLabel(self.str_not_connected.format(1)) ] self.current_current = [CurveValueWrapper(), CurveValueWrapper()] # float, mA plots = [('Sensor 0', Qt.red, self.current_current[0], lambda value: '{:.03f} mA'.format(round(value, 3))), ('Sensor 1', Qt.blue, self.current_current[1], lambda value: '{:.03f} mA'.format(round(value, 3)))] self.plot_widget = PlotWidget('Current [mA]', plots, extra_key_widgets=self.connected_labels, y_resolution=0.001) self.sample_rate_label = QLabel('Sample Rate:') self.sample_rate_combo = QComboBox() self.sample_rate_combo.addItem('240 Hz') self.sample_rate_combo.addItem('60 Hz') self.sample_rate_combo.addItem('15 Hz') self.sample_rate_combo.addItem('4 Hz') self.sample_rate_combo.currentIndexChanged.connect( self.sample_rate_combo_index_changed) hlayout = QHBoxLayout() hlayout.addWidget(self.sample_rate_label) hlayout.addWidget(self.sample_rate_combo) hlayout.addStretch() line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def add_tx_stats(self, vbox): hbox_stats = QHBoxLayout() # left column vbox_left = QVBoxLayout() self.tx_desc = TxDetailLabel(word_wrap=True) vbox_left.addWidget(self.tx_desc) self.status_label = TxDetailLabel() vbox_left.addWidget(self.status_label) self.date_label = TxDetailLabel() vbox_left.addWidget(self.date_label) self.amount_label = TxDetailLabel() vbox_left.addWidget(self.amount_label) self.ln_amount_label = TxDetailLabel() vbox_left.addWidget(self.ln_amount_label) fee_hbox = QHBoxLayout() self.fee_label = TxDetailLabel() fee_hbox.addWidget(self.fee_label) self.fee_warning_icon = QLabel() pixmap = QPixmap(icon_path("warning")) pixmap_size = round(2 * char_width_in_lineedit()) pixmap = pixmap.scaled(pixmap_size, pixmap_size, Qt.KeepAspectRatio, Qt.SmoothTransformation) self.fee_warning_icon.setPixmap(pixmap) self.fee_warning_icon.setToolTip( _("Warning") + ": " + _("The fee could not be verified. Signing non-segwit inputs is risky:\n" "if this transaction was maliciously modified before you sign,\n" "you might end up paying a higher mining fee than displayed.")) self.fee_warning_icon.setVisible(False) fee_hbox.addWidget(self.fee_warning_icon) fee_hbox.addStretch(1) vbox_left.addLayout(fee_hbox) name_fee_hbox = QHBoxLayout() self.name_fee_label = TxDetailLabel() name_fee_hbox.addWidget(self.name_fee_label) name_fee_hbox.addStretch(1) vbox_left.addLayout(name_fee_hbox) vbox_left.addStretch(1) hbox_stats.addLayout(vbox_left, 50) # vertical line separator line_separator = QFrame() line_separator.setFrameShape(QFrame.VLine) line_separator.setFrameShadow(QFrame.Sunken) line_separator.setLineWidth(1) hbox_stats.addWidget(line_separator) # right column vbox_right = QVBoxLayout() self.size_label = TxDetailLabel() vbox_right.addWidget(self.size_label) self.rbf_label = TxDetailLabel() vbox_right.addWidget(self.rbf_label) self.rbf_cb = QCheckBox(_('Replace by fee')) self.rbf_cb.setChecked(bool(self.config.get('use_rbf', True))) vbox_right.addWidget(self.rbf_cb) self.locktime_final_label = TxDetailLabel() vbox_right.addWidget(self.locktime_final_label) locktime_setter_hbox = QHBoxLayout() locktime_setter_hbox.setContentsMargins(0, 0, 0, 0) locktime_setter_hbox.setSpacing(0) locktime_setter_label = TxDetailLabel() locktime_setter_label.setText("LockTime: ") self.locktime_e = LockTimeEdit() locktime_setter_hbox.addWidget(locktime_setter_label) locktime_setter_hbox.addWidget(self.locktime_e) locktime_setter_hbox.addStretch(1) self.locktime_setter_widget = QWidget() self.locktime_setter_widget.setLayout(locktime_setter_hbox) vbox_right.addWidget(self.locktime_setter_widget) self.block_height_label = TxDetailLabel() vbox_right.addWidget(self.block_height_label) vbox_right.addStretch(1) hbox_stats.addLayout(vbox_right, 50) vbox.addLayout(hbox_stats) # below columns self.block_hash_label = TxDetailLabel(word_wrap=True) vbox.addWidget(self.block_hash_label) # set visibility after parenting can be determined by Qt self.rbf_label.setVisible(self.finalized) self.rbf_cb.setVisible(not self.finalized) self.locktime_final_label.setVisible(self.finalized) self.locktime_setter_widget.setVisible(not self.finalized)
class DeviceDialog(QDialog): def __init__(self, is_bluetooth=False): super().__init__() self.is_bluetooth = is_bluetooth if self.is_bluetooth: type = 'Bluetooth' target_type = 'address' else: type = 'serial' target_type = 'port' self.setWindowIcon(QtGui.QIcon('icons/pulse.svg')) self.setWindowTitle(str('Select or enter ' + type + ' device')) self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel) self.buttonBox.rejected.connect(self.close) self.scanButton = QtGui.QPushButton(self) self.scanButton.setText(str('Scan for ' + type + ' devices')) self.scanButton.clicked.connect(self.scan) self.horizontalSpacer = QFrame() self.horizontalSpacer.setFrameShape(QFrame.HLine) self.deviceTextBox = QLineEdit(self) self.deviceTextBox.returnPressed.connect(self.onReturnPressed) self.deviceTextBoxLabel = QLabel(self) self.deviceTextBoxLabel.setText( str('Enter device ' + target_type + ':')) self.devicesTable = QTableWidget() # Make the table uneditable self.devicesTable.setEditTriggers( QtGui.QAbstractItemView.NoEditTriggers) if self.is_bluetooth: self.devicesTable.setRowCount(0) self.devicesTable.setColumnCount(2) self.devicesTable.setHorizontalHeaderLabels( ('MAC address', 'Device name')) else: self.devicesTable.setRowCount(0) self.devicesTable.setColumnCount(1) self.devicesTable.setHorizontalHeaderLabels( ['List of serial ports']) self.devicesTable.horizontalHeader().setStretchLastSection(True) self.devicesTable.itemDoubleClicked.connect(self.onItemClicked) self.infoTable = QTableWidget() # Make the table uneditable self.infoTable.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) self.infoTable.setRowCount(4) self.infoTable.setColumnCount(1) self.infoTable.setHorizontalHeaderLabels(['Information string']) self.infoTable.horizontalHeader().setStretchLastSection(True) self.infoTable.setVerticalHeaderLabels( ['Vendor', 'Model', 'User', 'Stored data']) self.infoTable.resizeRowsToContents() self.infoTable.resizeColumnsToContents() self.infoTable.itemDoubleClicked.connect(self.onDeviceClicked) self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.addWidget(self.deviceTextBoxLabel) self.verticalLayout.addWidget(self.deviceTextBox) self.verticalLayout.addWidget(self.horizontalSpacer) self.verticalLayout.addWidget(self.scanButton) self.verticalLayout.addWidget(self.devicesTable) self.verticalLayout.addWidget(self.infoTable) self.verticalLayout.addWidget(self.buttonBox) self.resize(600, 800) def scan(self): """Scan for devices and populate table with results. """ self.scanButton.setText('Scanning ...') QtGui.QApplication.processEvents() devicescan = cms50ew.DeviceScan(is_bluetooth=self.is_bluetooth) row = 0 if self.is_bluetooth: self.devicesTable.setRowCount(len(devicescan.devices_dict)) for address, name in devicescan.devices_dict.items(): self.devicesTable.setItem(row, 0, QTableWidgetItem(address)) self.devicesTable.setItem(row, 1, QTableWidgetItem(name)) row += 1 else: self.devicesTable.setRowCount(len(devicescan.accessible_ports)) for port in devicescan.accessible_ports: self.devicesTable.setItem(row, 0, QTableWidgetItem(port)) row += 1 self.scanButton.setText('Scan finished') QtGui.QApplication.processEvents() def onItemClicked(self): """Get wanted device from table and retrieve information""" item = self.devicesTable.selectedItems()[0] self.target = self.devicesTable.item(item.row(), 0).text() self.getDeviceInformation() def getDeviceInformation(self): self.scanButton.setText('Retrieving info from ' + self.target + ' ...') QtGui.QApplication.processEvents() oxi = cms50ew.CMS50EW() oxi.setup_device(self.target, is_bluetooth=self.is_bluetooth) if not oxi.initiate_device(): self.scanButton.setText('No response from device') QtGui.QApplication.processEvents() else: oxi.get_model() oxi.get_vendor() oxi.get_user() oxi.get_session_count() oxi.get_session_duration() self.infoTable.setItem(0, 0, QTableWidgetItem(oxi.vendor)) self.infoTable.setItem(1, 0, QTableWidgetItem(oxi.model)) self.infoTable.setItem(2, 0, QTableWidgetItem(oxi.user)) self.infoTable.setItem( 3, 0, QTableWidgetItem( str(oxi.sess_available + ' (Duration: ' + str(oxi.sess_duration) + ')'))) self.scanButton.setText('Device information received') QtGui.QApplication.processEvents() def onDeviceClicked(self): self.setupDevice() def onReturnPressed(self): self.target = self.deviceTextBox.text() self.setupDevice() def setupDevice(self): self.scanButton.setText('Connecting to ' + self.target + ' ...') QtGui.QApplication.processEvents() w.oxi = cms50ew.CMS50EW() if w.oxi.setup_device(self.target, is_bluetooth=self.is_bluetooth): if w.oxi.is_bluetooth: w.statusBar.showMessage( 'Status: Connected to Bluetooth device') else: w.statusBar.showMessage('Status: Opened serial port') w.liveRunAction.setEnabled(True) w.sessDialogAction.setEnabled(True) self.close() else: w.statusBar.showMessage('Status: Connection attempt unsuccessful') self.close()
def HLine(): toto = QFrame() toto.setFrameShape(QFrame.HLine) toto.setFrameShadow(QFrame.Sunken) return toto
def __init__(self, parent=None, ihm_type='pc'): super(RobotStatusWidget, self).__init__(None) self._client = None self._time_wid = QLineEdit() self._x_wid = QLineEdit() self._y_wid = QLineEdit() self._button = QPushButton('Emergency Stop') self._robot_state_wid = QLineEdit('') self._robot_side_wid = QLineEdit('') self._sensors_wid = QLabel() self._gpio_wid = QLabel() self._debug_goldo_wid = QLabel() self._time_wid.setReadOnly(True) layout = QGridLayout() layout.addWidget(QLabel('time:'), 0, 0) layout.addWidget(self._time_wid, 0, 1, 1, 1) layout.addWidget(QLabel('DbgGoldo:'), 0, 2, 1, 1) layout.addWidget(self._debug_goldo_wid, 0, 3, 1, 1) layout.addWidget(self._robot_state_wid, 1, 0, 1, 1) layout.addWidget(self._robot_side_wid, 1, 1, 1, 1) layout.addWidget(self._sensors_wid, 1, 2, 1, 1) layout.addWidget(self._gpio_wid, 1, 3, 1, 1) frame = QFrame() frame.setFrameShape(QFrame.HLine) layout.addWidget(frame, 2, 0, 1, 2) if ihm_type == 'pc': self._telemetry_props = PropertiesEditorWidget( None, [('pose.position.x', float, lambda x: '{:0>6.1f}'.format(x * 1000.0)), ('pose.position.y', float, lambda x: '{:0>6.1f}'.format(x * 1000.0)), ('pose.yaw', float, lambda x: '{:0>5.1f}'.format(x * 180.0 / math.pi)), ('pose.speed', float, '{:0>3.2f}'), ('pose.yaw_rate', float, '{:0>3.2f}'), ('pose.acceleration', float), ('pose.angular_acceleration', float), ('left_encoder', float, '{:0>4}'), ('right_encoder', float, '{:0>4}'), ( 'left_pwm', float, ), ( 'right_pwm', float, ), ('state', int, lambda x: _controller_state[x]), ('error', int, lambda x: _controller_error[x])], True) else: self._telemetry_props = PropertiesEditorWidget( None, [( 'x', float, ), ( 'y', float, ), ( 'yaw', float, )], True) if ihm_type == 'pc': self._telemetry_ex_props = PropertiesEditorWidget( None, [ #('target_x', float,), #('target_y', float,), #('target_yaw', float,), #('target_speed', float,), #('target_yaw_rate', float,), ('error_longi', float, '{:0>1.2f}'), ('error_lateral', float, '{:0>1.2f}'), ('error_yaw', float, '{:0>1.2f}'), ('error_speed', float, '{:0>1.2f}'), ('error_yaw_rate', float, '{:0>1.2f}') ], True) else: self._telemetry_ex_props = PropertiesEditorWidget(None, [], True) layout.addWidget(self._telemetry_props, 3, 0, 1, 2) layout.addWidget(self._telemetry_ex_props, 4, 0, 1, 2) layout.addWidget(self._button, 5, 0, 1, 2) self.setLayout(layout) self._button.clicked.connect(self._on_emergency_stop_button_clicked) self._sensors_wid.setText('sensors') self.goldo_dbg_info = 0
class MainWindow_Ui(QMainWindow): def __init__(self, persepolis_setting): super().__init__() # MainWindow self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' self.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", "Persepolis Download Manager")) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.centralwidget = QWidget(self) self.verticalLayout = QVBoxLayout(self.centralwidget) # enable drag and drop self.setAcceptDrops(True) # frame self.frame = QFrame(self.centralwidget) # download_table_horizontalLayout download_table_horizontalLayout = QHBoxLayout() horizontal_splitter = QSplitter(Qt.Horizontal) vertical_splitter = QSplitter(Qt.Vertical) # category_tree self.category_tree_qwidget = QWidget(self) category_tree_verticalLayout = QVBoxLayout() self.category_tree = CategoryTreeView(self) category_tree_verticalLayout.addWidget(self.category_tree) self.category_tree_model = QStandardItemModel() self.category_tree.setModel(self.category_tree_model) category_table_header = [ QCoreApplication.translate("mainwindow_ui_tr", 'Category') ] self.category_tree_model.setHorizontalHeaderLabels( category_table_header) self.category_tree.header().setStretchLastSection(True) self.category_tree.header().setDefaultAlignment(Qt.AlignCenter) # queue_panel self.queue_panel_widget = QWidget(self) queue_panel_verticalLayout_main = QVBoxLayout(self.queue_panel_widget) # queue_panel_show_button self.queue_panel_show_button = QPushButton(self) queue_panel_verticalLayout_main.addWidget(self.queue_panel_show_button) # queue_panel_widget_frame self.queue_panel_widget_frame = QFrame(self) self.queue_panel_widget_frame.setFrameShape(QFrame.StyledPanel) self.queue_panel_widget_frame.setFrameShadow(QFrame.Raised) queue_panel_verticalLayout_main.addWidget( self.queue_panel_widget_frame) queue_panel_verticalLayout = QVBoxLayout(self.queue_panel_widget_frame) queue_panel_verticalLayout_main.setContentsMargins(50, -1, 50, -1) # start_end_frame self.start_end_frame = QFrame(self) # start time start_verticalLayout = QVBoxLayout(self.start_end_frame) self.start_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.start_checkBox) self.start_frame = QFrame(self) self.start_frame.setFrameShape(QFrame.StyledPanel) self.start_frame.setFrameShadow(QFrame.Raised) start_frame_verticalLayout = QVBoxLayout(self.start_frame) self.start_time_qDataTimeEdit = QDateTimeEdit(self.start_frame) self.start_time_qDataTimeEdit.setDisplayFormat('H:mm') start_frame_verticalLayout.addWidget(self.start_time_qDataTimeEdit) start_verticalLayout.addWidget(self.start_frame) # end time self.end_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.end_checkBox) self.end_frame = QFrame(self) self.end_frame.setFrameShape(QFrame.StyledPanel) self.end_frame.setFrameShadow(QFrame.Raised) end_frame_verticalLayout = QVBoxLayout(self.end_frame) self.end_time_qDateTimeEdit = QDateTimeEdit(self.end_frame) self.end_time_qDateTimeEdit.setDisplayFormat('H:mm') end_frame_verticalLayout.addWidget(self.end_time_qDateTimeEdit) start_verticalLayout.addWidget(self.end_frame) self.reverse_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.reverse_checkBox) queue_panel_verticalLayout.addWidget(self.start_end_frame) # limit_after_frame self.limit_after_frame = QFrame(self) # limit_checkBox limit_verticalLayout = QVBoxLayout(self.limit_after_frame) self.limit_checkBox = QCheckBox(self) limit_verticalLayout.addWidget(self.limit_checkBox) # limit_frame self.limit_frame = QFrame(self) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) limit_verticalLayout.addWidget(self.limit_frame) limit_frame_verticalLayout = QVBoxLayout(self.limit_frame) # limit_spinBox limit_frame_horizontalLayout = QHBoxLayout() self.limit_spinBox = QDoubleSpinBox(self) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) limit_frame_horizontalLayout.addWidget(self.limit_spinBox) # limit_comboBox self.limit_comboBox = QComboBox(self) self.limit_comboBox.addItem("") self.limit_comboBox.addItem("") limit_frame_horizontalLayout.addWidget(self.limit_comboBox) limit_frame_verticalLayout.addLayout(limit_frame_horizontalLayout) # limit_pushButton self.limit_pushButton = QPushButton(self) limit_frame_verticalLayout.addWidget(self.limit_pushButton) # after_checkBox self.after_checkBox = QCheckBox(self) limit_verticalLayout.addWidget(self.after_checkBox) # after_frame self.after_frame = QFrame(self) self.after_frame.setFrameShape(QFrame.StyledPanel) self.after_frame.setFrameShadow(QFrame.Raised) limit_verticalLayout.addWidget(self.after_frame) after_frame_verticalLayout = QVBoxLayout(self.after_frame) # after_comboBox self.after_comboBox = QComboBox(self) self.after_comboBox.addItem("") after_frame_verticalLayout.addWidget(self.after_comboBox) # after_pushButton self.after_pushButton = QPushButton(self) after_frame_verticalLayout.addWidget(self.after_pushButton) queue_panel_verticalLayout.addWidget(self.limit_after_frame) category_tree_verticalLayout.addWidget(self.queue_panel_widget) # keep_awake_checkBox self.keep_awake_checkBox = QCheckBox(self) queue_panel_verticalLayout.addWidget(self.keep_awake_checkBox) self.category_tree_qwidget.setLayout(category_tree_verticalLayout) horizontal_splitter.addWidget(self.category_tree_qwidget) # download table widget self.download_table_content_widget = QWidget(self) download_table_content_widget_verticalLayout = QVBoxLayout( self.download_table_content_widget) # download_table self.download_table = DownloadTableWidget(self) vertical_splitter.addWidget(self.download_table) horizontal_splitter.addWidget(self.download_table_content_widget) self.download_table.setColumnCount(13) self.download_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.download_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.download_table.verticalHeader().hide() # hide gid and download dictioanry section self.download_table.setColumnHidden(8, True) self.download_table.setColumnHidden(9, True) download_table_header = [ QCoreApplication.translate("mainwindow_ui_tr", 'File Name'), QCoreApplication.translate("mainwindow_ui_tr", 'Status'), QCoreApplication.translate("mainwindow_ui_tr", 'Size'), QCoreApplication.translate("mainwindow_ui_tr", 'Downloaded'), QCoreApplication.translate("mainwindow_ui_tr", 'Percentage'), QCoreApplication.translate("mainwindow_ui_tr", 'Connections'), QCoreApplication.translate("mainwindow_ui_tr", 'Transfer rate'), QCoreApplication.translate("mainwindow_ui_tr", 'Estimated time left'), 'Gid', QCoreApplication.translate("mainwindow_ui_tr", 'Link'), QCoreApplication.translate("mainwindow_ui_tr", 'First try date'), QCoreApplication.translate("mainwindow_ui_tr", 'Last try date'), QCoreApplication.translate("mainwindow_ui_tr", 'Category') ] self.download_table.setHorizontalHeaderLabels(download_table_header) # fixing the size of download_table when window is Maximized! self.download_table.horizontalHeader().setSectionResizeMode(0) self.download_table.horizontalHeader().setStretchLastSection(True) horizontal_splitter.setStretchFactor(0, 3) # category_tree width horizontal_splitter.setStretchFactor(1, 10) # ratio of tables's width # video_finder_widget self.video_finder_widget = QWidget(self) video_finder_horizontalLayout = QHBoxLayout(self.video_finder_widget) self.muxing_pushButton = QPushButton(self) self.muxing_pushButton.setIcon(QIcon(icons + 'video_finder')) video_finder_horizontalLayout.addWidget(self.muxing_pushButton) video_finder_horizontalLayout.addSpacing(20) video_audio_verticalLayout = QVBoxLayout() self.video_label = QLabel(self) video_audio_verticalLayout.addWidget(self.video_label) self.audio_label = QLabel(self) video_audio_verticalLayout.addWidget(self.audio_label) video_finder_horizontalLayout.addLayout(video_audio_verticalLayout) status_muxing_verticalLayout = QVBoxLayout() self.video_finder_status_label = QLabel(self) status_muxing_verticalLayout.addWidget(self.video_finder_status_label) self.muxing_status_label = QLabel(self) status_muxing_verticalLayout.addWidget(self.muxing_status_label) video_finder_horizontalLayout.addLayout(status_muxing_verticalLayout) vertical_splitter.addWidget(self.video_finder_widget) download_table_content_widget_verticalLayout.addWidget( vertical_splitter) download_table_horizontalLayout.addWidget(horizontal_splitter) self.frame.setLayout(download_table_horizontalLayout) self.verticalLayout.addWidget(self.frame) self.setCentralWidget(self.centralwidget) # menubar self.menubar = QMenuBar(self) self.menubar.setGeometry(QRect(0, 0, 600, 24)) self.setMenuBar(self.menubar) fileMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&File')) editMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Edit')) viewMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&View')) downloadMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Download')) queueMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Queue')) videoFinderMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", 'V&ideo Finder')) helpMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Help')) # viewMenu submenus sortMenu = viewMenu.addMenu( QCoreApplication.translate("mainwindow_ui_tr", 'Sort by')) # statusbar self.statusbar = QStatusBar(self) self.setStatusBar(self.statusbar) self.statusbar.showMessage( QCoreApplication.translate("mainwindow_ui_tr", "Persepolis Download Manager")) # toolBar self.toolBar2 = QToolBar(self) self.addToolBar(Qt.TopToolBarArea, self.toolBar2) self.toolBar2.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", 'Menu')) self.toolBar2.setFloatable(False) self.toolBar2.setMovable(False) self.toolBar = QToolBar(self) self.addToolBar(Qt.TopToolBarArea, self.toolBar) self.toolBar.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", 'Toolbar')) self.toolBar.setFloatable(False) self.toolBar.setMovable(False) #toolBar and menubar and actions self.persepolis_setting.beginGroup('settings/shortcuts') # videoFinderAddLinkAction self.videoFinderAddLinkAction = QAction( QIcon(icons + 'video_finder'), QCoreApplication.translate("mainwindow_ui_tr", 'Find Video Links'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Download video or audio from Youtube, Vimeo, etc...'), triggered=self.showVideoFinderAddLinkWindow) self.videoFinderAddLinkAction_shortcut = QShortcut( self.persepolis_setting.value('video_finder_shortcut'), self, self.showVideoFinderAddLinkWindow) videoFinderMenu.addAction(self.videoFinderAddLinkAction) # stopAllAction self.stopAllAction = QAction(QIcon(icons + 'stop_all'), QCoreApplication.translate( "mainwindow_ui_tr", 'Stop all active downloads'), self, statusTip='Stop all active downloads', triggered=self.stopAllDownloads) downloadMenu.addAction(self.stopAllAction) # sort_file_name_Action self.sort_file_name_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'File name'), self, triggered=self.sortByName) sortMenu.addAction(self.sort_file_name_Action) # sort_file_size_Action self.sort_file_size_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'File size'), self, triggered=self.sortBySize) sortMenu.addAction(self.sort_file_size_Action) # sort_first_try_date_Action self.sort_first_try_date_Action = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'First try date'), self, triggered=self.sortByFirstTry) sortMenu.addAction(self.sort_first_try_date_Action) # sort_last_try_date_Action self.sort_last_try_date_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'Last try date'), self, triggered=self.sortByLastTry) sortMenu.addAction(self.sort_last_try_date_Action) # sort_download_status_Action self.sort_download_status_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'Download status'), self, triggered=self.sortByStatus) sortMenu.addAction(self.sort_download_status_Action) # trayAction self.trayAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show system tray icon'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Show/Hide system tray icon"), triggered=self.showTray) self.trayAction.setCheckable(True) viewMenu.addAction(self.trayAction) # showMenuBarAction self.showMenuBarAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show menubar'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Show menubar'), triggered=self.showMenuBar) self.showMenuBarAction.setCheckable(True) viewMenu.addAction(self.showMenuBarAction) # showSidePanelAction self.showSidePanelAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show side panel'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Show side panel'), triggered=self.showSidePanel) self.showSidePanelAction.setCheckable(True) viewMenu.addAction(self.showSidePanelAction) # minimizeAction self.minimizeAction = QAction( QIcon(icons + 'minimize'), QCoreApplication.translate("mainwindow_ui_tr", 'Minimize to system tray'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Minimize to system tray"), triggered=self.minMaxTray) self.minimizeAction_shortcut = QShortcut( self.persepolis_setting.value('hide_window_shortcut'), self, self.minMaxTray) viewMenu.addAction(self.minimizeAction) # addlinkAction self.addlinkAction = QAction( QIcon(icons + 'add'), QCoreApplication.translate("mainwindow_ui_tr", 'Add New Download Link'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Add New Download Link"), triggered=self.addLinkButtonPressed) self.addlinkAction_shortcut = QShortcut( self.persepolis_setting.value('add_new_download_shortcut'), self, self.addLinkButtonPressed) fileMenu.addAction(self.addlinkAction) # importText self.addtextfileAction = QAction( QIcon(icons + 'file'), QCoreApplication.translate("mainwindow_ui_tr", 'Import links from text file'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Create a Text file and put links in it.line by line!'), triggered=self.importText) self.addtextfileAction_shortcut = QShortcut( self.persepolis_setting.value('import_text_shortcut'), self, self.importText) fileMenu.addAction(self.addtextfileAction) # resumeAction self.resumeAction = QAction( QIcon(icons + 'play'), QCoreApplication.translate("mainwindow_ui_tr", 'Resume Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Resume Download"), triggered=self.resumeButtonPressed) downloadMenu.addAction(self.resumeAction) # pauseAction self.pauseAction = QAction( QIcon(icons + 'pause'), QCoreApplication.translate("mainwindow_ui_tr", 'Pause Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Pause Download"), triggered=self.pauseButtonPressed) downloadMenu.addAction(self.pauseAction) # stopAction self.stopAction = QAction( QIcon(icons + 'stop'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Stop/Cancel Download"), triggered=self.stopButtonPressed) downloadMenu.addAction(self.stopAction) # propertiesAction self.propertiesAction = QAction( QIcon(icons + 'setting'), QCoreApplication.translate("mainwindow_ui_tr", 'Properties'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Properties"), triggered=self.propertiesButtonPressed) downloadMenu.addAction(self.propertiesAction) # progressAction self.progressAction = QAction( QIcon(icons + 'window'), QCoreApplication.translate("mainwindow_ui_tr", 'Progress'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Progress"), triggered=self.progressButtonPressed) downloadMenu.addAction(self.progressAction) # openFileAction self.openFileAction = QAction( QIcon(icons + 'file'), QCoreApplication.translate("mainwindow_ui_tr", 'Open file'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open file'), triggered=self.openFile) fileMenu.addAction(self.openFileAction) # openDownloadFolderAction self.openDownloadFolderAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate("mainwindow_ui_tr", 'Open download folder'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open download folder'), triggered=self.openDownloadFolder) fileMenu.addAction(self.openDownloadFolderAction) # openDefaultDownloadFolderAction self.openDefaultDownloadFolderAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate("mainwindow_ui_tr", 'Open default download folder'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Open default download folder'), triggered=self.openDefaultDownloadFolder) fileMenu.addAction(self.openDefaultDownloadFolderAction) # exitAction self.exitAction = QAction( QIcon(icons + 'exit'), QCoreApplication.translate("mainwindow_ui_tr", 'Exit'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Exit"), triggered=self.closeAction) self.exitAction_shortcut = QShortcut( self.persepolis_setting.value('quit_shortcut'), self, self.closeAction) fileMenu.addAction(self.exitAction) # clearAction self.clearAction = QAction(QIcon(icons + 'multi_remove'), QCoreApplication.translate( "mainwindow_ui_tr", 'Clear download list'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Clear all items in download list'), triggered=self.clearDownloadList) editMenu.addAction(self.clearAction) # removeSelectedAction self.removeSelectedAction = QAction( QIcon(icons + 'remove'), QCoreApplication.translate("mainwindow_ui_tr", 'Remove selected downloads from list'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Remove selected downloads form list'), triggered=self.removeSelected) self.removeSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('remove_shortcut'), self, self.removeSelected) editMenu.addAction(self.removeSelectedAction) self.removeSelectedAction.setEnabled(False) # deleteSelectedAction self.deleteSelectedAction = QAction( QIcon(icons + 'trash'), QCoreApplication.translate("mainwindow_ui_tr", 'Delete selected download files'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Delete selected download files'), triggered=self.deleteSelected) self.deleteSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('delete_shortcut'), self, self.deleteSelected) editMenu.addAction(self.deleteSelectedAction) self.deleteSelectedAction.setEnabled(False) # moveSelectedDownloadsAction self.moveSelectedDownloadsAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate( "mainwindow_ui_tr", 'move selected download files to another folder'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'move selected download files to another folder'), triggered=self.moveSelectedDownloads) editMenu.addAction(self.moveSelectedDownloadsAction) self.moveSelectedDownloadsAction.setEnabled(False) # createQueueAction self.createQueueAction = QAction( QIcon(icons + 'add_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Create new queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Create new download queue'), triggered=self.createQueue) queueMenu.addAction(self.createQueueAction) # removeQueueAction self.removeQueueAction = QAction( QIcon(icons + 'remove_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Remove this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Remove this queue'), triggered=self.removeQueue) queueMenu.addAction(self.removeQueueAction) # startQueueAction self.startQueueAction = QAction( QIcon(icons + 'start_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Start this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Start this queue'), triggered=self.startQueue) queueMenu.addAction(self.startQueueAction) # stopQueueAction self.stopQueueAction = QAction( QIcon(icons + 'stop_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Stop this queue'), triggered=self.stopQueue) queueMenu.addAction(self.stopQueueAction) # moveUpSelectedAction self.moveUpSelectedAction = QAction( QIcon(icons + 'multi_up'), QCoreApplication.translate("mainwindow_ui_tr", 'Move up selected items'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move currently selected items up by one row'), triggered=self.moveUpSelected) self.moveUpSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('move_up_selection_shortcut'), self, self.moveUpSelected) queueMenu.addAction(self.moveUpSelectedAction) # moveDownSelectedAction self.moveDownSelectedAction = QAction( QIcon(icons + 'multi_down'), QCoreApplication.translate("mainwindow_ui_tr", 'Move down selected items'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move currently selected items down by one row'), triggered=self.moveDownSelected) self.moveDownSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('move_down_selection_shortcut'), self, self.moveDownSelected) queueMenu.addAction(self.moveDownSelectedAction) # preferencesAction self.preferencesAction = QAction( QIcon(icons + 'preferences'), QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'), triggered=self.openPreferences, menuRole=5) editMenu.addAction(self.preferencesAction) # aboutAction self.aboutAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'About'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'About'), triggered=self.openAbout, menuRole=4) helpMenu.addAction(self.aboutAction) # issueAction self.issueAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Report an issue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Report an issue'), triggered=self.reportIssue) helpMenu.addAction(self.issueAction) # updateAction self.updateAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Check for newer version'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Check for newer release'), triggered=self.newUpdate) helpMenu.addAction(self.updateAction) # logAction self.logAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Show log file'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'), triggered=self.showLog) helpMenu.addAction(self.logAction) # helpAction self.helpAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Help'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'), triggered=self.persepolisHelp) helpMenu.addAction(self.helpAction) self.persepolis_setting.endGroup() self.qmenu = MenuWidget(self) self.toolBar2.addWidget(self.qmenu) # labels self.queue_panel_show_button.setText( QCoreApplication.translate("mainwindow_ui_tr", "Hide options")) self.start_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Start Time")) self.end_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "End Time")) self.reverse_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Download bottom of\n the list first")) self.limit_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Limit Speed")) self.limit_comboBox.setItemText(0, "KiB/s") self.limit_comboBox.setItemText(1, "MiB/s") self.limit_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Apply")) self.after_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "After download")) self.after_comboBox.setItemText( 0, QCoreApplication.translate("mainwindow_ui_tr", "Shut Down")) self.keep_awake_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Keep system awake!")) self.keep_awake_checkBox.setToolTip( QCoreApplication.translate( "mainwindow_ui_tr", "<html><head/><body><p>This option is preventing system from going to sleep.\ This is necessary if your power manager is suspending system automatically. </p></body></html>" )) self.after_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Apply")) self.muxing_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "start muxing")) self.video_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Video file status: </b>")) self.audio_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Audio file status: </b>")) self.video_finder_status_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Status: </b>")) self.muxing_status_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Muxing status: </b>"))
class MissionEditor(QWidget): # Set up signals spawn_waypoint_signal = QtCore.pyqtSignal(PoseWithCovarianceStamped) set_enable_go_to_buttons = QtCore.pyqtSignal(bool) set_enable_send_mission = QtCore.pyqtSignal(bool) def __init__(self, parent): super(QWidget, self).__init__(parent) self.robot_pose = None # Set up topic subsribers self.robot_pose_sub = rospy.Subscriber("/robot_pose", PoseStamped, self.robot_pose_cb) self.spawn_waypoint_sub = rospy.Subscriber( "spawn_waypoint", PoseWithCovarianceStamped, lambda msg: self.spawn_waypoint_signal.emit(msg)) # Connect signal self.spawn_waypoint_signal.connect(self.spawn_waypoint) self.v_layout = QVBoxLayout(self) # Title set up self.title_label = QLabel('Mission Editor') self.title_label.setFont(QFont('Ubuntu', 11, QFont.Bold)) self.title_label.setAlignment(Qt.AlignRight) self.v_layout.addWidget(self.title_label) # Title set up self.editor_title_label = QLabel('Editor:') self.editor_title_label.setFont(QFont('Ubuntu', 10, QFont.Bold)) self.v_layout.addWidget(self.editor_title_label) # Waypoint list self.waypoint_list = QWaypointListWidget() self.v_layout.addWidget(self.waypoint_list, 5) # Buttons self.add_here_button = QPushButton('Add Here') self.duplicate_button = QPushButton('Duplicate') self.delete_button = QPushButton('Delete') self.delete_all_button = QPushButton('Delete All') self.save_mission_button = QPushButton('Save Mission') self.load_mission_button = QPushButton('Load Mission') self.add_here_button.pressed.connect(self.add_here) self.duplicate_button.pressed.connect(self.duplicate) self.delete_button.pressed.connect(self.delete) self.delete_all_button.pressed.connect(self.delete_all) self.save_mission_button.pressed.connect(self.save) self.load_mission_button.pressed.connect(self.load) self.button_layout = QGridLayout() self.button_layout.addWidget(self.add_here_button, 0, 0) self.button_layout.addWidget(self.duplicate_button, 0, 1) self.button_layout.addWidget(self.delete_button, 1, 0) self.button_layout.addWidget(self.delete_all_button, 1, 1) self.button_layout.addWidget(self.save_mission_button, 2, 0) self.button_layout.addWidget(self.load_mission_button, 2, 1) self.v_layout.addLayout(self.button_layout) # Line self.line = QFrame() self.line.setFrameShape(QFrame.HLine) self.line.setFrameShadow(QFrame.Sunken) self.v_layout.addWidget(self.line) # Send command self.command_title = QLabel('Send Command:') self.command_title.setFont(QFont('Ubuntu', 10, QFont.Bold)) self.v_layout.addWidget(self.command_title) # Command buttons self.h_layout_command = QHBoxLayout() self.go_to_selected_button = QPushButton('Go to Selected') self.go_to_selected_button.pressed.connect(self.go_to_selected) self.go_to_all_button = QPushButton('Go to All') self.go_to_all_button.pressed.connect(self.go_to_all) self.enable_go_to_buttons(False) self.set_enable_go_to_buttons.connect(self.enable_go_to_buttons) self.send_mission_button = QPushButton('Send Mission') self.send_mission_button.pressed.connect(self.send_mission) self.enable_send_mission_button(False) self.set_enable_send_mission.connect(self.enable_send_mission_button) self.h_layout_command.addWidget(self.go_to_selected_button) self.h_layout_command.addWidget(self.go_to_all_button) self.h_layout_command.addWidget(self.send_mission_button) self.v_layout.addLayout(self.h_layout_command) self.emergency_stop_widget = EmergencyStop(self) self.v_layout.addWidget(self.emergency_stop_widget) self.setLayout(self.v_layout) self.bt_action = BuildBTAction() self.mb_action = WaypointMoveBaseAction() # Setup state checker: self.bt_state_checker = rr_qt_helper.StateCheckerTimer( self.bt_action.is_connected, self.set_enable_send_mission, Hz=1. / 3.) self.bt_state_checker.start() self.mb_state_checker = rr_qt_helper.StateCheckerTimer( self.mb_action.is_connected, self.set_enable_go_to_buttons, Hz=1. / 3.) self.mb_state_checker.start() def robot_pose_cb(self, msg): self.robot_pose = msg def spawn_waypoint(self, pwcs_msg): msg = TaskWaypointMsg() pose_stamped = PoseStamped() pose_stamped.header = pwcs_msg.header pose_stamped.pose = pwcs_msg.pose.pose msg.pose_stamped = pose_stamped self.waypoint_list.append(self.waypoint_list.new_waypoint(msg)) def add_here(self): if self.robot_pose: msg = PoseWithCovarianceStamped() msg.header = self.robot_pose.header msg.pose.pose = self.robot_pose.pose self.spawn_waypoint_signal.emit(msg) else: rospy.logwarn("Robot pose not connected") def duplicate(self): if self.waypoint_list.get_selected_wp(): self.waypoint_list.duplicate(self.waypoint_list.get_selected_wp()) def delete(self): if self.waypoint_list.get_selected_wp(): self.waypoint_list.remove(self.waypoint_list.get_selected_wp()) def delete_all(self): for _ in range(self.waypoint_list.len()): self.waypoint_list.remove( self.waypoint_list.get_wp(self.waypoint_list.len() - 1)) def save(self): mission_name, ok = QInputDialog.getText( self, "Mission file name", "Specify file name to save mission:") if ok: if mission_name == "": mission_name = "default" if mission_name[-5:] == ".yaml": mission_name = mission_name[0:-5] mission_name = string.replace(mission_name, '.', '_') mission_name = mission_name + ".yaml" save_path = file_management.get_mission_files_dir( ) + "/" + mission_name self.waypoint_list.saveToPath(save_path, "Mission" + str(rospy.Time.now())) def load(self): mission_files = file_management.get_files( file_management.get_mission_files_dir(), ".yaml") if mission_files == []: msg = QMessageBox() msg.setWindowTitle("Load Mission") msg.setIcon(QMessageBox.Information) msg.setText("No mission files available") msg.setStandardButtons(QMessageBox.Ok) msg.exec_() else: mission_file, ok = QInputDialog.getItem(self, "Select mission to load", "Available missions:", mission_files, 0, False) if ok: load_path = file_management.get_mission_files_dir( ) + "/" + mission_file if load_path[-5:] != ".yaml": load_path = load_path + ".yaml" self.waypoint_list.loadFromPath(load_path) def enable_go_to_buttons(self, enabled): self.go_to_selected_button.setEnabled(enabled) self.go_to_all_button.setEnabled(enabled) def enable_send_mission_button(self, enabled): self.send_mission_button.setEnabled(enabled) def go_to_selected(self): self.mb_action.goto_action(self.waypoint_list) def go_to_all(self): self.mb_action.gotoall_action(self.waypoint_list) def send_mission(self): self.bt_action.build_bt_action(self.waypoint_list)
class MainWindow(QMainWindow): def __init__(self, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) self.image_wh = 384 self.setWindowTitle("Cassava Leaf") self.main_layout = QVBoxLayout() self.main_widget = QWidget() self.main_widget.setLayout(self.main_layout) self.separatorLine1 = QFrame() self.separatorLine1.setFrameShape(QFrame.HLine) self.separatorLine2 = QFrame() self.separatorLine2.setFrameShape(QFrame.HLine) self.first_part() self.second_part() self.third_part() self.setCentralWidget(self.main_widget) self.model = CassavaModel() def first_part(self): """ First layout with 'help' button """ self.first_layout = QHBoxLayout() self.first_layout.addStretch(1) self.info_button = QPushButton("Help") self.info_button.clicked.connect(self.help) self.info_button.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)) self.first_layout.addWidget(self.info_button) self.main_layout.addLayout(self.first_layout) def second_part(self): """ Second layout of uploading photo. """ self.path = "" self.first_frame = QFrame() self.first_frame.setFrameShape(QFrame.StyledPanel) self.second_layout = QHBoxLayout() self.first_left_layout = QVBoxLayout() self.upload_text = QPlainTextEdit("address of photo") self.upload_text.setFixedHeight(24*2) self.upload_text.setFixedWidth(self.image_wh) self.first_left_layout.addWidget(self.upload_text) self.choosen_image = QLabel() self.choosen_image.setPixmap(QPixmap("Graphics/unknown.png").scaled(self.image_wh, self.image_wh)) self.first_left_layout.addWidget(self.choosen_image) self.second_layout.addLayout(self.first_left_layout) self.first_right_layout = QVBoxLayout() self.upload_button = QPushButton("Browse") self.upload_button.clicked.connect(self.choose_file) self.upload_button.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)) self.first_right_layout.addWidget(self.upload_button) self.first_right_layout.addStretch(1) self.check_button = QPushButton("Confirm") self.check_button.clicked.connect(self.confirm_file) self.check_button.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)) self.first_right_layout.addWidget(self.check_button) self.second_layout.addLayout(self.first_right_layout) self.first_frame.setLayout(self.second_layout) self.main_layout.addWidget(self.first_frame) def third_part(self): """ Third layout of showing results (disease and link to wiki). """ self.second_frame = QFrame() self.second_frame.setFrameShape(QFrame.StyledPanel) self.third_layout = QHBoxLayout() self.second_left_frame = QVBoxLayout() self.disease_name = QPlainTextEdit("name of disease") self.disease_name.setFixedWidth(self.image_wh) self.disease_name.setEnabled(False) self.disease_name.setTextInteractionFlags(Qt.TextSelectableByMouse) self.disease_name.setFixedHeight(24) self.second_left_frame.addWidget(self.disease_name) self.disease_picture = QLabel() self.disease_picture.setPixmap(QPixmap("Graphics/known.png").scaled(self.image_wh, self.image_wh)) self.second_left_frame.addWidget(self.disease_picture) self.third_layout.addLayout(self.second_left_frame) self.second_right_frame = QVBoxLayout() self.second_right_frame.addStretch(1) self.disease_desc = QPushButton("about the disease") self.disease_desc.setEnabled(False) self.disease_desc.clicked.connect(self.open_wiki) self.disease_desc.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)) self.second_right_frame.addWidget(self.disease_desc) self.third_layout.addLayout(self.second_right_frame) self.second_frame.setLayout(self.third_layout) self.main_layout.addWidget(self.second_frame) def help(self): """ Opening popup window with useful informations. """ msg = QMessageBox() msg.setWindowTitle("Help window") line_1 = "Press 'Browse' button and select photo of leaf." line_2 = "When you choosen the photo, press 'Confirm' button." line_3 = "In the lower part, you will see a leaf disease." line_4 = "You can see a book example of the disease" line_5 = "and read more on Wikipedia." lines = [line_1, line_2, line_3, line_4, line_5] msg.setText("\n".join(lines)) msg.setIcon(QMessageBox.Information) msg.exec_() def resize_pixmap(self, pixmap, new_wh): """ Resizing pixmap to the same width and height (new_wh). """ return pixmap.scaled(new_wh, new_wh) def choose_file(self): """ Choosing the photo with leaf from drives. """ path, _ = QFileDialog.getOpenFileName(self, "Choose the photo", "c\\", "png files (*.png *.jpg)") if path != "": self.path = path self.check_button.setEnabled(True) self.upload_text.setPlainText(self.path) self.choosen_image.setPixmap(QPixmap(self.path).scaled(self.image_wh, self.image_wh)) def confirm_file(self): """ Confirming the photo with leaf. """ if self.path != "": self.detected_diss, self.acc = self.model.predict(self.path) self.disease_name.setEnabled(True) self.disease_desc.setEnabled(True) self.disease_name.setPlainText(self.detected_diss) self.disease_picture.setPixmap(QPixmap(f"Graphics/{labels[self.detected_diss][0]}.png").scaled(self.image_wh, self.image_wh)) def open_wiki(self): """ Opening wiki page with dissease of leaf. """ url = labels[self.detected_diss][1] url = QUrl(url) QDesktopServices.openUrl(url)
def frame(self): frame = QFrame() frame.setFrameShape(QFrame.StyledPanel) frame.setLineWidth(0.6) frame.setStyleSheet('background-color:blue') self.hbox.addWidget(frame)
def initUI(self): self.timer = QBasicTimer() self.step = 0 #全局布局 self.GlobalLayout = QHBoxLayout() #三个按钮 self.fasong_btn1 = QPushButton('存储', self) self.fasong_btn1.setFixedSize(100, 60) self.fasong_btn1.clicked.connect(self.cunchu) self.fasong_btn2 = QPushButton('温度', self) self.fasong_btn2.setFixedSize(100, 60) self.fasong_btn2.clicked.connect(self.wendu) self.fasong_btn3 = QPushButton('工作状态', self) self.fasong_btn3.setFixedSize(100, 60) self.fasong_btn3.clicked.connect(self.work) #存储按钮 self.cunchu_btn1 = QPushButton('', self) self.cunchu_btn1.setFixedSize(50, 50) self.cunchu_btn2 = QPushButton('', self) self.cunchu_btn2.setFixedSize(50, 50) self.cunchu_btn3 = QPushButton('', self) self.cunchu_btn3.setFixedSize(50, 50) self.cunchu_btn4 = QPushButton('', self) self.cunchu_btn4.setFixedSize(50, 50) self.cunchu_btn5 = QPushButton('', self) self.cunchu_btn5.setFixedSize(50, 50) self.cunchu_btn6 = QPushButton('', self) self.cunchu_btn6.setFixedSize(50, 50) self.cunchu_btn7 = QPushButton('', self) self.cunchu_btn7.setFixedSize(50, 50) self.cunchu_btn8 = QPushButton('', self) self.cunchu_btn8.setFixedSize(50, 50) self.cunchu_btn9 = QPushButton('', self) self.cunchu_btn9.setFixedSize(50, 50) self.cunchu_btn10 = QPushButton('', self) self.cunchu_btn10.setFixedSize(50, 50) self.cunchu_btn11 = QPushButton('', self) self.cunchu_btn11.setFixedSize(50, 50) self.cunchu_btn12 = QPushButton('', self) self.cunchu_btn12.setFixedSize(50, 50) self.cunchu_btn13 = QPushButton('', self) self.cunchu_btn13.setFixedSize(50, 50) self.cunchu_btn14 = QPushButton('', self) self.cunchu_btn14.setFixedSize(50, 50) self.cunchu_btn15 = QPushButton('', self) self.cunchu_btn15.setFixedSize(50, 50) self.cunchu_btn16 = QPushButton('', self) self.cunchu_btn16.setFixedSize(50, 50) self.cunchu_btn17 = QPushButton('', self) self.cunchu_btn17.setFixedSize(50, 50) self.cunchu_btn18 = QPushButton('', self) self.cunchu_btn18.setFixedSize(50, 50) self.cunchu_btn19 = QPushButton('', self) self.cunchu_btn19.setFixedSize(50, 50) self.cunchu_btn20 = QPushButton('', self) self.cunchu_btn20.setFixedSize(50, 50) self.cunchu_btn21 = QPushButton('', self) self.cunchu_btn21.setFixedSize(50, 50) self.cunchu_btn22 = QPushButton('', self) self.cunchu_btn22.setFixedSize(50, 50) self.cunchu_btn23 = QPushButton('', self) self.cunchu_btn23.setFixedSize(50, 50) self.cunchu_btn24 = QPushButton('', self) self.cunchu_btn24.setFixedSize(50, 50) self.cunchu_btn25 = QPushButton('', self) self.cunchu_btn25.setFixedSize(50, 50) self.cunchu_btn26 = QPushButton('', self) self.cunchu_btn26.setFixedSize(50, 50) self.cunchu_btn27 = QPushButton('', self) self.cunchu_btn27.setFixedSize(50, 50) self.cunchu_btn28 = QPushButton('', self) self.cunchu_btn28.setFixedSize(50, 50) self.cunchu_btn29 = QPushButton('', self) self.cunchu_btn29.setFixedSize(50, 50) self.cunchu_btn30 = QPushButton('', self) self.cunchu_btn30.setFixedSize(50, 50) self.cunchu_btn31 = QPushButton('', self) self.cunchu_btn31.setFixedSize(50, 50) self.cunchu_btn32 = QPushButton('', self) self.cunchu_btn32.setFixedSize(50, 50) self.cunchu_btn33 = QPushButton('', self) self.cunchu_btn33.setFixedSize(50, 50) self.cunchu_btn34 = QPushButton('', self) self.cunchu_btn34.setFixedSize(50, 50) self.cunchu_btn35 = QPushButton('', self) self.cunchu_btn35.setFixedSize(50, 50) self.cunchu_btn36 = QPushButton('', self) self.cunchu_btn36.setFixedSize(50, 50) #左边框 vlayout = QVBoxLayout(self) vlayout.addWidget(self.fasong_btn1) vlayout.addWidget(self.fasong_btn2) vlayout.addWidget(self.fasong_btn3) #hbox = QHBoxLayout(self) ###将界面分割成可以自由拉伸的三个窗口 #第一个,左上角,图像显示框 topleft = QFrame(self) topleft.setFrameShape(QFrame.StyledPanel) topleft.setLayout(vlayout) #第二个,右上角串口选择框 self.topright = QStackedWidget(self) CunFrame = QFrame() CunFrame.setFrameShape(QFrame.StyledPanel) Cunlayout = QGridLayout() Cunlayout.addWidget(self.cunchu_btn1, 0, 0) Cunlayout.addWidget(self.cunchu_btn2, 0, 1) Cunlayout.addWidget(self.cunchu_btn3, 0, 2) Cunlayout.addWidget(self.cunchu_btn4, 0, 3) Cunlayout.addWidget(self.cunchu_btn5, 0, 4) Cunlayout.addWidget(self.cunchu_btn6, 0, 5) Cunlayout.addWidget(self.cunchu_btn7, 1, 0) Cunlayout.addWidget(self.cunchu_btn8, 1, 1) Cunlayout.addWidget(self.cunchu_btn9, 1, 2) Cunlayout.addWidget(self.cunchu_btn10, 1, 3) Cunlayout.addWidget(self.cunchu_btn11, 1, 4) Cunlayout.addWidget(self.cunchu_btn12, 1, 5) Cunlayout.addWidget(self.cunchu_btn13, 2, 0) Cunlayout.addWidget(self.cunchu_btn14, 2, 1) Cunlayout.addWidget(self.cunchu_btn15, 2, 2) Cunlayout.addWidget(self.cunchu_btn16, 2, 3) Cunlayout.addWidget(self.cunchu_btn17, 2, 4) Cunlayout.addWidget(self.cunchu_btn18, 2, 5) Cunlayout.addWidget(self.cunchu_btn19, 3, 0) Cunlayout.addWidget(self.cunchu_btn20, 3, 1) Cunlayout.addWidget(self.cunchu_btn21, 3, 2) Cunlayout.addWidget(self.cunchu_btn22, 3, 3) Cunlayout.addWidget(self.cunchu_btn23, 3, 4) Cunlayout.addWidget(self.cunchu_btn24, 3, 5) Cunlayout.addWidget(self.cunchu_btn25, 4, 0) Cunlayout.addWidget(self.cunchu_btn26, 4, 1) Cunlayout.addWidget(self.cunchu_btn27, 4, 2) Cunlayout.addWidget(self.cunchu_btn28, 4, 3) Cunlayout.addWidget(self.cunchu_btn29, 4, 4) Cunlayout.addWidget(self.cunchu_btn30, 4, 5) Cunlayout.addWidget(self.cunchu_btn31, 5, 0) Cunlayout.addWidget(self.cunchu_btn32, 5, 1) Cunlayout.addWidget(self.cunchu_btn33, 5, 2) Cunlayout.addWidget(self.cunchu_btn34, 5, 3) Cunlayout.addWidget(self.cunchu_btn35, 5, 4) Cunlayout.addWidget(self.cunchu_btn36, 5, 5) CunFrame.setLayout(Cunlayout) self.topright.addWidget(CunFrame) #温度 WenFrame = QFrame(self) WenFrame.setFrameShape(QFrame.StyledPanel) self.topright.addWidget(WenFrame) #工作状态 WorkFrame = QFrame(self) WorkFrame.setFrameShape(QFrame.StyledPanel) Worklayout = QVBoxLayout() self.WeiZhi_btn = QPushButton('未知血型', self) self.WeiZhi_btn.setFixedSize(80, 60) self.YiZhi_btn = QPushButton('已知血型', self) self.YiZhi_btn.setFixedSize(80, 60) self.ChuXue_btn = QPushButton('直接出血', self) self.ChuXue_btn.setFixedSize(80, 60) hFrame = QFrame() vFrame = QFrame() hwg = QHBoxLayout() vwg = QVBoxLayout() hwg.addWidget(self.WeiZhi_btn) hwg.addWidget(self.YiZhi_btn) hwg.addWidget(self.ChuXue_btn) self.prsbar = QProgressBar(self) vwg.addWidget(self.prsbar) hFrame.setLayout(hwg) vFrame.setLayout(vwg) Worklayout.addWidget(hFrame) Worklayout.addWidget(vFrame) WorkFrame.setLayout(Worklayout) self.topright.addWidget(WorkFrame) #第三个,底部,串口通信框 bottom = QFrame(self) bottom.setFrameShape(QFrame.StyledPanel) #调用splitter控件,使窗口可以拖动起来 splitter1 = QSplitter(Qt.Horizontal) splitter1.addWidget(topleft) splitter1.addWidget(self.topright) splitter1.setSizes([80, 600]) splitter2 = QSplitter(Qt.Vertical) splitter2.addWidget(splitter1) splitter2.addWidget(bottom) splitter2.setSizes([800, 200]) self.GlobalLayout.addWidget(splitter2) #topright.setLayout(hbox) self.setLayout(self.GlobalLayout) self.setGeometry(300, 300, 800, 600) self.setWindowTitle('吴洪岩') self.setWindowIcon(QIcon('Icon\meidui.JPG')) self.show()
def dialog_box(title, icon, errorText, warningText): dlg = QDialog() scroll = QScrollArea(dlg) widget = QWidget() vbox = QVBoxLayout() labelN = QLabel(notice, objectName='labelN') lineE = QFrame(objectName='lineE') lineE.setFrameShape(QFrame.HLine) labelE1 = QLabel(objectName='labelE1') labelE2 = QLabel() lineW = QFrame(objectName='lineW') lineW.setFrameShape(QFrame.HLine) labelW1 = QLabel(objectName='labelW1') labelW2 = QLabel() vbox.addWidget(labelN) vbox.addWidget(lineE) vbox.addWidget(labelE1) vbox.addWidget(labelE2) vbox.addWidget(lineW) vbox.addWidget(labelW1) vbox.addWidget(labelW2) widget.setLayout(vbox) btn = QPushButton('OK', dlg) dlg.setWindowTitle(title) dlg.setWindowIcon(QIcon(dlg.style().standardIcon(icon))) dlg.setWindowFlags(Qt.WindowStaysOnTopHint) dlg.setModal(False) dlg.setFixedWidth(600) dlg.setFixedHeight(310) scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll.setWidgetResizable(True) scroll.setWidget(widget) scroll.setGeometry(5, 5, 590, 250) btn.move(270, 260) btn.clicked.connect(lambda w: dlg_ok_clicked(dlg)) if errorText: labelE1.setText(errors) labelE2.setText(errorText) else: lineE.hide() labelE1.hide() labelE2.hide() if warningText: labelW1.setText(warnings) labelW2.setText(warningText) else: lineW.hide() labelW1.hide() labelW2.hide() dlg.setStyleSheet(' \ * {{ color: {0}; background: {1}}} \ QScrollArea {{color:{0}; background:{1}; border:1px solid {0}; border-radius:4px; padding:4px}} \ QPushButton {{border:2px solid {0}; border-radius:4px; font:12pt; width:60px; height:40px}} \ QPushButton:pressed {{border:1px solid {0}}} \ QScrollBar:vertical {{background:{2}; border:0px; border-radius:4px; margin: 0px; width:20px}} \ QScrollBar::handle:vertical {{background:{0}; border:2px solid {0}; border-radius:4px; margin:2px; min-height:40px}} \ QScrollBar::add-line:vertical {{height:0px}} \ QScrollBar::sub-line:vertical {{height:0px}} \ QVboxLayout {{margin:100}} \ #labelN {{font-style:italic}} \ #lineE, #lineW {{border:1px solid {0}}} \ #labelE1, #labelW1 {{font-weight:bold}}'.format( fgColor, bgColor, bgAltColor)) dlg.exec()
def _createdisplay(self): spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) ''' File location ''' # file label, lineEdit and tool button file_label = QLabel("File:") file_label.setAlignment(QtCore.Qt.AlignCenter) self.file_lineedit = QLineEdit() self.file_lineedit.setPlaceholderText("---select file location---") self.file_lineedit.setReadOnly(True) self.file_toolbtn = QPushButton('...') self.file_toolbtn.setFixedSize(26, 22) layout = QGridLayout() layout.addWidget(file_label, 0, 0) layout.addWidget(self.file_lineedit, 0, 1, 1, 4) layout.addWidget(self.file_toolbtn, 0, 5) ''' semester and level selector''' # semester label and combobox s_label = QLabel("Semester:") s_label.setAlignment(QtCore.Qt.AlignCenter) self.s_combobox = QComboBox() self.s_combobox.addItem("--select--") self.s_combobox.addItem('First') self.s_combobox.addItem('Second') # semester and label layouts s_layout = QHBoxLayout() s_layout.addWidget(s_label) s_layout.addWidget(self.s_combobox) # level label and combo box l_label = QLabel("Level:") l_label.setAlignment(QtCore.Qt.AlignCenter) self.l_combobox = QComboBox() self.l_combobox.addItem('--select--') #self.l_combobox.addItem('100') self.l_combobox.addItem('200') self.l_combobox.addItem('300') self.l_combobox.addItem('400') self.l_combobox.addItem('500') #level layout l_layout = QHBoxLayout() l_layout.addWidget(l_label) l_layout.addWidget(self.l_combobox) # semester and level layout. ALso the layout for the file lineEdit id included S_L_layout = QGridLayout() S_L_layout.addLayout(layout, 0, 0, 1, 4) S_L_layout.addLayout(s_layout, 1, 0) S_L_layout.addLayout(l_layout, 2, 0) # semester and level frame s_frame = QFrame() s_frame.setLayout(S_L_layout) s_frame.setFrameShadow(QFrame.Raised) s_frame.setFrameShape(QFrame.StyledPanel) self.generallayout.addWidget(s_frame, 0, 0) #self.generallayout.addItem(spacer,1,1,1,2) ''' Faculty and Department selector''' # faculty selector f_label = QLabel("Faculty:") f_label.setAlignment(QtCore.Qt.AlignCenter) f_combo = QComboBox() f_combo.addItem('--select--') f_combo.addItem("SEET") f_combo.addItem("SAAT") f_combo.addItem("SET") f_combo.addItem("SICT") f_combo.addItem("SEMT") # faculty layout f_layout = QHBoxLayout() f_layout.addWidget(f_label) f_layout.addWidget(f_combo) # Department selector d_label = QLabel("Department:") d_label.setAlignment(QtCore.Qt.AlignCenter) d_combo = QComboBox() d_combo.addItem('--select--') d_combo.addItem('ABE') d_combo.addItem('CIVIL') d_combo.addItem('COMPUTER') d_combo.addItem('TELECOMS') d_combo.addItem('MAT & MET') d_combo.addItem('CHEMICAL') d_combo.addItem('MECHANICAL') d_combo.addItem('MECHATRONICS') # department layout d_layout = QHBoxLayout() d_layout.addWidget(d_label) d_layout.addWidget(d_combo) # faculty and department layout f_d_layout = QGridLayout() f_d_layout.addLayout(f_layout, 1, 3) f_d_layout.addLayout(d_layout, 2, 3) # faculty and department frame f_d_frame = QFrame() f_d_frame.setLayout(f_d_layout) f_d_frame.setFrameShadow(QFrame.Raised) f_d_frame.setFrameShape(QFrame.StyledPanel) self.generallayout.addWidget(f_d_frame, 0, 4) ''' table view widget ''' index = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ] self.table = QTableWidget(7, 8) rol = 0 for item in index: day = QTableWidgetItem(item) self.table.setItem(rol, 0, day) rol += 1 self.table.setShowGrid(True) self.table.setEditTriggers(QAbstractItemView.NoEditTriggers) # table layout table_layout = QGridLayout() table_layout.addWidget(self.table, 0, 0, 1, 5) # table view frame t_frame = QFrame() t_frame.setLayout(table_layout) t_frame.setFrameShadow(QFrame.Raised) t_frame.setFrameShape(QFrame.StyledPanel) self.generallayout.addWidget(t_frame, 1, 0, 3, 5) ''' push pushbuttons ''' self.g_button = QPushButton("Generate") self.e_button = QPushButton("Export") # buttons layout btn_layout = QGridLayout() btn_layout.addWidget(self.g_button, 5, 0) btn_layout.addWidget(self.e_button, 5, 1) # button frame btn_frame = QFrame() btn_frame.setLayout(btn_layout) self.generallayout.addWidget(btn_frame, 5, 2)
class WelcomeInterf(object): def __init__(self): # la fenetre self.Dialog = QWidget() self.Dialog.setWindowTitle("Welcome on our FlashCard program") self.Dialog.resize(936, 582) # le layout de la bande du haute self.ligneFixeWidget = QWidget(self.Dialog) self.ligneFixeWidget.setGeometry(QtCore.QRect(10, 10, 891, 41)) self.ligneFixe = QHBoxLayout(self.ligneFixeWidget) self.ligneFixe.setContentsMargins(0, 0, 0, 0) # la barre et le bouton de recherche self.searchBar = QLineEdit(self.ligneFixeWidget) self.ligneFixe.addWidget(self.searchBar) self.searchButton = QPushButton(u"Search", self.ligneFixeWidget) self.ligneFixe.addWidget(self.searchButton) # un espace (futur nom + logo ?) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.ligneFixe.addItem(spacerItem) # le bouton de modification # ne peut pas ouvrir directement l'interface de modification car il faut sélectioner une carte self.modifyButton = QPushButton(u"Modify", self.ligneFixeWidget) self.ligneFixe.addWidget(self.modifyButton) # le bouton d'mportation / exportation # pas encore gere non plus ; a venir ? self.importButton = QtWidgets.QPushButton(u"Import", self.ligneFixeWidget) self.ligneFixe.addWidget(self.importButton) self.importButton.setEnabled(False) # le bouton de creation d'une nouvelle carte self.newButton = QtWidgets.QPushButton(u"New Card", self.ligneFixeWidget) self.ligneFixe.addWidget(self.newButton) # le bouton des réglages de l'application self.settingsButton = QtWidgets.QPushButton(u"Settings", self.ligneFixeWidget) self.ligneFixe.addWidget(self.settingsButton) # la barre de resume sur le cote self.ResumeBox = QGroupBox(self.Dialog) self.ResumeBox.setGeometry(QtCore.QRect(10, 60, 211, 501)) self.barreResume = QVBoxLayout(self.ResumeBox) # bouton d'accueil # determiner quel affichage self.accueil = QPushButton(u"Accueil", self.ResumeBox) self.barreResume.addWidget(self.accueil) self.accueil.setEnabled(True) #bouton de language self.editlanguage = QComboBox(self.ResumeBox) self.langues = database.giveAllLanguages() for languespossibles in self.langues: self.editlanguage.addItem(languespossibles) self.barreResume.addWidget(self.editlanguage) self.Table = self.editlanguage.currentText() self.getCards() # une ligne de séparation horizontale self.line1 = QFrame(self.ResumeBox) self.line1.setFrameShape(QFrame.HLine) self.line1.setFrameShadow(QFrame.Sunken) self.barreResume.addWidget(self.line1) # label cartes a apprendre et les 3 boutons carte associés self.learnlabel = QLabel(self.ResumeBox) self.learnlabel.setText(" Cards to learn") self.barreResume.addWidget(self.learnlabel) self.learn1 = ConnectedButton(self.cardsToLearn, 0, self.ResumeBox, "learn1", self.openViewCards) self.barreResume.addWidget(self.learn1) self.learn2 = ConnectedButton(self.cardsToLearn, 1, self.ResumeBox, "learn2", self.openViewCards) self.barreResume.addWidget(self.learn2) self.learn3 = ConnectedButton(self.cardsToLearn, 2, self.ResumeBox, "learn3", self.openViewCards) self.barreResume.addWidget(self.learn3) # label cartes a revoir et les 3 boutons carte associés self.overlabel = QLabel(self.ResumeBox) self.overlabel.setText(" Cards to go over") self.barreResume.addWidget(self.overlabel) self.over1 = ConnectedButton(self.cardsToGoOver, 0, self.ResumeBox, "over1", self.openViewCards) self.barreResume.addWidget(self.over1) self.over2 = ConnectedButton(self.cardsToGoOver, 1, self.ResumeBox, "over2", self.openViewCards) self.barreResume.addWidget(self.over2) self.over3 = ConnectedButton(self.cardsToGoOver, 2, self.ResumeBox, "over3", self.openViewCards) self.barreResume.addWidget(self.over3) # label cartes bien connues et les 3 boutons carte associés self.knowledgelabel = QLabel(self.ResumeBox) self.knowledgelabel.setText(" Cards known") self.barreResume.addWidget(self.knowledgelabel) self.know1 = ConnectedButton(self.cardsKnown, 0, self.ResumeBox, "know1", self.openViewCards) self.barreResume.addWidget(self.know1) self.know2 = ConnectedButton(self.cardsKnown, 1, self.ResumeBox, "know2", self.openViewCards) self.barreResume.addWidget(self.know2) self.know3 = ConnectedButton(self.cardsKnown, 2, self.ResumeBox, "know3", self.openViewCards) self.barreResume.addWidget(self.know3) # une ligne de séparation horizontale self.line2 = QFrame(self.ResumeBox) self.line2.setFrameShape(QFrame.HLine) self.line2.setFrameShadow(QFrame.Sunken) self.barreResume.addWidget(self.line2) # le bouton d'aideopenCardSignal=QtCore.pyqtSignal(str, int) self.helpButton = QPushButton(u"Help", self.ResumeBox) self.barreResume.addWidget(self.helpButton) self.helpButton.setEnabled(False) ## ecran central changeant # au moment de l'ouverture ecran d'accueil # plus tard interface de parcours de carte, de lecture de cartes, # de jeu et de parcours de jeu ### le layout central avec les onglets self.screenLayout = QWidget(self.Dialog) self.screenLayout.setGeometry(QtCore.QRect(230, 60, 671, 501)) self.myscreen = HomeScreen(self.screenLayout, self.editlanguage.currentText()) #raccourcis self.closeShortcut = QShortcut(QtGui.QKeySequence('Ctrl+c'), self.Dialog) ## gestion des slots et des signaux self.createInterf = None self.newButton.clicked.connect(self.createnew) self.accueil.clicked.connect(self.retourAccueil) self.selectedcard = None self.modifInterf = None self.modifyButton.clicked.connect(self.modifycard) self.searchInterf = None self.settingsButton.clicked.connect(self.changeMySettings) self.SettingsInterf = None self.currentScreen = self.myscreen self.searchButton.clicked.connect(self.search) self.learn1.clicked.connect(self.learn1.open) self.learn2.clicked.connect(self.learn2.open) self.learn3.clicked.connect(self.learn3.open) self.over1.clicked.connect(self.over1.open) self.over2.clicked.connect(self.over2.open) self.over3.clicked.connect(self.over3.open) self.know1.clicked.connect(self.know1.open) self.know2.clicked.connect(self.know2.open) self.know3.clicked.connect(self.know3.open) self.closeShortcut.activated.connect(self.Dialog.close) self.editlanguage.activated.connect(self.changeLanguage) self.myscreen.dragAndDropSignal.connect(self.openDragAndDrop) self.myscreen.hotAndColdSignal.connect(self.openHotAndCold) self.myscreen.openLanguageSignal.connect(self.openParcours) self.myscreen.rightWrongSignal.connect(self.openVraiOuFaux) self.myscreen.memorySignal.connect(self.openMemory) self.myscreen.pointSignal.connect(self.openPointTo) def changeLanguage(self): self.Table = self.editlanguage.currentText() self.getCards() self.myscreen.language = self.Table self.myscreen.MesJeux.language = self.Table self.learn1.changeCardList(self.cardsToLearn) self.learn2.changeCardList(self.cardsToLearn) self.learn3.changeCardList(self.cardsToLearn) self.over1.changeCardList(self.cardsToGoOver) self.over2.changeCardList(self.cardsToGoOver) self.over3.changeCardList(self.cardsToGoOver) self.know1.changeCardList(self.cardsKnown) self.know2.changeCardList(self.cardsKnown) self.know3.changeCardList(self.cardsKnown) def getCards(self): self.cardsToLearn = database.getCardsToLearn(self.Table, 0, 4) self.cardsToGoOver = database.getCardsToLearn(self.Table, 5, 9) self.cardsKnown = database.getCardsToLearn(self.Table, 10, 10) def show(self): # ouverture de la fenetre self.Dialog.show() def retourAccueil(self): self.currentScreen.close() self.currentScreen = self.myscreen self.displayHomeScreen() def createnew(self): # ouverture de l'interface de creation self.currentScreen.close() self.createInterf = createcardsInterf.CardCreation(self.screenLayout) self.currentScreen = self.createInterf self.createInterf.show() self.createInterf.created.connect(self.displayHomeScreen) def modifycard(self): # la carte pour l'instant random self.selectedcard = database.getCardById( "anglais", database.getRandomCard("anglais")) # ouverture de l'interface de modification self.modifInterf = createcardsInterf.CardModification( self.screenLayout, self.selectedcard) #on cache l'ecran d'accueil self.currentScreen.close() self.currentScreen = self.modifInterf self.modifInterf.show() self.modifInterf.modified.connect(self.displayHomeScreen) self.modifInterf.deleted.connect(self.displayHomeScreen) def changeMySettings(self): # ouverture de l'interface de creation self.currentScreen.close() self.SettingsInterf = settingsInterf.mySettings(self.screenLayout) self.currentScreen = self.SettingsInterf self.SettingsInterf.show() self.SettingsInterf.updated.connect(self.displayHomeScreen) def openParcours(self, language): self.currentScreen.close() self.parcoursInterf = parcours.parcoursChosenCards( self.screenLayout, language) self.currentScreen = self.parcoursInterf self.currentScreen.show() self.parcoursInterf.openCardSignal.connect(self.openCard) def openCard(self, language, rank): self.openViewCards(rank, database.getAllCards(language)) def openDragAndDrop(self): self.currentScreen.close() self.DDInterf = dragAndDrop.dragDropGame( self.screenLayout, database.getCardsToLearn(self.Table, 0, 9)) self.DDInterf.show() self.currentScreen = self.DDInterf self.DDInterf.leave.connect(self.displayHomeScreen) def openHotAndCold(self): self.currentScreen.close() self.HCInterf = hotColdGame.hotColdGame( self.screenLayout, database.getCardsToLearn(self.Table, 0, 9)) self.HCInterf.show() self.currentScreen = self.HCInterf self.HCInterf.leave.connect(self.displayHomeScreen) def openVraiOuFaux(self): self.currentScreen.close() self.VFInterf = vraiOuFaux.vraiFauxGame( self.screenLayout, database.getCardsToLearn(self.Table, 0, 9)) self.VFInterf.show() self.currentScreen = self.VFInterf self.VFInterf.leave.connect(self.displayHomeScreen) def openViewCards(self, rank, cardlist): self.currentScreen.close() self.linkedInterf = viewCard.viewDialog(self.screenLayout, rank, cardlist) self.linkedInterf.show() self.currentScreen = self.linkedInterf def openMemory(self): self.currentScreen.close() self.MemoryInterf = memory.MemoryGameWindow( self.screenLayout, database.getCardsToLearn(self.Table, 0, 9)) self.MemoryInterf.show() self.currentScreen = self.MemoryInterf self.MemoryInterf.leave.connect(self.displayHomeScreen) def openPointTo(self): self.currentScreen.close() self.PointToInterf = pointToCard.pointToCardGame( self.screenLayout, database.getCardsToLearn(self.Table, 0, 9)) self.PointToInterf.show() self.currentScreen = self.PointToInterf self.PointToInterf.leave.connect(self.displayHomeScreen) def displayHomeScreen(self): self.getCards() self.myscreen.setVisible(True) self.currentScreen = self.myscreen def search(self): self.searchInterf = rechercheInterf.Recherche() tosearch = self.searchBar.text() self.searchInterf.lineE_mot.setText(tosearch) self.searchInterf.click_btn_lancer() self.searchInterf.show()
class FormMain(QWidget, Ui_FormMain): """ FormMain is a widget that displays and runs a user defined form """ def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget @type QWidget """ super(FormMain, self).__init__(parent) # parent is the frame widget of the parent form that the form widget will be displayed in self.parent = parent self.setupUi(self) self.formDict = None self.formItemList = [] self.topFrame = None def findParentItem(self, parentID = None): returnItem = None returnItem = [item for item in self.formItemList if item.itemDict["idNum"] == parentID] if len(returnItem) > 0: return returnItem[0] def clearForm(self): '''clear all generated widgets from the top level frame ''' self.topFrame.setParent(None) del self.topFrame def frame_clicked(self, ): '''a frame was clicked on ''' print("clicked on frame:".format()) def generateForm(self, formDict=None): if not formDict is None: # create the list of form items self.formDict = formDict self.formItemList = [] if not self.topFrame is None: self.clearForm() # generate fromes and widgets if len(self.formDict["formOutline"]) > 0: for formItemDict in self.formDict["formOutline"]: # create the form item object and add it to the list if formItemDict["type"] == "Form": formItem = FormDef(itemDict=formItemDict) self.formItemList.append(formItem) if formItemDict["type"] == "Row": formItem = FormRowDef(itemDict=formItemDict) self.formItemList.append(formItem) if formItemDict["type"] == "Widget": if formItemDict["widgetType"] == "Label": formItem = LabelWidgetDef(itemDict=formItemDict) if formItemDict["widgetType"] == "Button": formItem = ButtonWidgetDef(itemDict=formItemDict) if not formItem is None: self.formItemList.append(formItem) else: print("no items defined for the form") return # create frame objects and populate with ui widgets for formItem in self.formItemList: if formItem.itemDict["type"] == "Form": # add top level frame to the parent print("add to top level layout") # create frame object self.topFrame = QFrame(self.frmMain) self.topFrame.setFrameShape(QFrame.Panel) self.topFrame.setFrameShadow(QFrame.Plain) self.topFrame.setObjectName(formItem.itemDict["itemName"]) # create a layout for the frome on the UI_FormMain self.horizontalLayout = QtWidgets.QHBoxLayout(self.frmMain) self.horizontalLayout.setContentsMargins(1, 1, 1, 1) self.horizontalLayout.setSpacing(1) self.horizontalLayout.setObjectName("formMainLayout") # add the forms top frame to it's parents layout self.frmMain.layout().addWidget(self.topFrame) # create a vertical layout for the frome self.vLayout = QtWidgets.QVBoxLayout(self.topFrame) self.vLayout.setContentsMargins(1, 1, 1, 1) self.vLayout.setSpacing(1) self.vLayout.setObjectName("{}layout".format(formItem.itemDict["itemName"])) # tell this formItem what his frame is formItem.frame = self.topFrame # tell this formItem who is parent frame is formItem.parentFrame = self.parent elif not formItem.itemDict["parentID"] is None: # get the parent formItem parentItem = self.findParentItem(formItem.itemDict["parentID"]) print("add {}:{} to parent: {}".format(formItem.itemDict["type"], formItem.itemDict["itemName"], parentItem.itemDict["itemName"])) if formItem.itemDict["type"] == "Row": # create frame object self.newFrame = FrameWidget(formItem=formItem, parentFrame=parentItem.frame) # add the frame to it's parents layout parentItem.frame.layout().addWidget(self.newFrame) # tell this formItem what his frame is formItem.frame = self.newFrame # tell this formItem who its parent frame is formItem.parentFrame = parentItem.frame elif formItem.itemDict["type"] == "Widget": if formItem.itemDict["widgetType"] == "Label": # create label widget newWidget = LabelWidget(formItem=formItem, parentFrame=parentItem.frame) newWidget.setText(formItem.itemDict["text"]) if formItem.itemDict["widgetType"] == "Button": # create label widget newWidget = ButtonWidget(formItem=formItem, parentFrame=parentItem.frame) newWidget.setText(formItem.itemDict["text"]) # tell this formItem who its widget and parent frame is formItem.widget = newWidget formItem.parentFrame = parentItem.frame def frameMousePress(self): print("frame mouse press")
def initUI(self): mainMenu = self.menuBar() fileMenu = mainMenu.addMenu('File') OpenButton = QAction(QIcon('Open.png'), 'Open File', self) OpenButton.setShortcut('Ctrl+O') OpenButton.setStatusTip('Select a Binary for Network Analysis') OpenButton.triggered.connect(self.on_click_load) fileMenu.addAction(OpenButton) exitButton = QAction(QIcon('exit24.png'), 'Exit', self) exitButton.setShortcut('Ctrl+Q') exitButton.setStatusTip('Exit application') exitButton.triggered.connect(self.close) fileMenu.addAction(exitButton) leftFrame = QFrame(self) leftFrame.setFrameShape(QFrame.StyledPanel) fileTitle = QLabel(self) formatTitle = QLabel(self) archTitle = QLabel(self) endianTitle = QLabel(self) feedbackTitle = QLabel(self) fileTitle.setText("File:") formatTitle.setText("Format:") archTitle.setText("Arch:") endianTitle.setText("Endian:") feedbackTitle.setText("Feedback:") global file, format, arch, endian, feedback file = QLabel(self) format = QLabel(self) arch = QLabel(self) endian = QLabel(self) feedback = QLabel(self) leftLayout = QVBoxLayout() fileLayout = QHBoxLayout() fileLayout.addWidget(fileTitle) fileLayout.addWidget(file) fileLayout.addStretch() leftLayout.addLayout(fileLayout) formatLayout = QHBoxLayout() formatLayout.addWidget(formatTitle) formatLayout.addWidget(format) formatLayout.addStretch() leftLayout.addLayout(formatLayout) archLayout = QHBoxLayout() archLayout.addWidget(archTitle) archLayout.addWidget(arch) archLayout.addStretch() leftLayout.addLayout(archLayout) endianLayout = QHBoxLayout() endianLayout.addWidget(endianTitle) endianLayout.addWidget(endian) endianLayout.addStretch() leftLayout.addLayout(endianLayout) feedbackLayout = QHBoxLayout() feedbackLayout.addWidget(feedbackTitle) feedbackLayout.addWidget(feedback) feedbackLayout.addStretch() leftLayout.addLayout(feedbackLayout) leftLayout.addStretch() leftFrame.setLayout(leftLayout) rightFrame = QFrame(self) rightFrame.setFrameShape(QFrame.StyledPanel) rightLayout = QVBoxLayout() tabs = QTabWidget() tab1 = QWidget() tab2 = QWidget() tab3 = QWidget() # Add tabs tabs.addTab(tab1, "Network Plugin") tabs.addTab(tab2, "Plugin 2") tabs.addTab(tab3, "Plugin 3") staticButton = QPushButton('Static Analysis', tab1) staticButton.setToolTip('Statically analyze the binary.') staticButton.move(200, 70) staticButton.clicked.connect(self.on_click_static) dynamicButton = QPushButton('Dynamic Analysis', tab1) dynamicButton.setToolTip('Dynamically analyze the binary.') dynamicButton.move(310, 70) dynamicButton.clicked.connect(self.on_click_dynamic) tab1.layout = QVBoxLayout() tab1.layout.addWidget(staticButton) tab1.layout.addWidget(dynamicButton) rightLayout.addWidget(tabs) rightFrame.setLayout(rightLayout) leftFrame.setGeometry(QtCore.QRect(0, 0, 20, 800)) self.splitter = QSplitter(Qt.Horizontal) self.splitter.addWidget(leftFrame) self.splitter.addWidget(rightFrame) self.setCentralWidget(self.splitter) self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) self.show()
class RightForm1(QFrame): """ 右侧框体1 """ def __init__(self): super(RightForm1, self).__init__() self.init() self.setup_ui() self.set_form_layout() def init(self): pass def setup_ui(self): # ***************左侧****************** self.loadingFrame = QFrame() self.loadingFrame.setObjectName('loadingFrame') self.loadingFrame.setFrameShape(QFrame.StyledPanel) # 最小化以及设置按钮管理栏 self.loadingFrameBar = QWidget(self.loadingFrame) self.loadingFrameBar.setObjectName('loadingFrameBar') self.loadingFrameBar.resize(self.loadingFrame.width(), 20) self.loadingFrameSettingBtn = QPushButton(self.loadingFrameBar) self.loadingFrameSettingBtn.setIcon( QIcon('./image/mainWindowIcon/RightForm1Image/setting.png')) self.loadingFrameSettingBtn.setMaximumWidth(30) self.loadingFrameMinBtn = QPushButton(self.loadingFrameBar) self.loadingFrameMinBtn.setIcon( QIcon('./image/mainWindowIcon/RightForm1Image/min.png')) self.loadingFrameMinBtn.setMaximumWidth(30) self.loadingFrameMinBtn.clicked.connect(lambda: self.hide_loadframe()) # 选项卡面板 self.loadingTab = QTabWidget(self.loadingFrame) self.loadingTab.setObjectName('loadingTab') # *********图片加载模式UI设计********** self.imageLoadingForm = QWidget(self.loadingTab) self.imageLoadingForm.setObjectName('imageLoadingForm') self.form1_a = QWidget(self.imageLoadingForm) self.form1_a.setObjectName('form1_a') self.groupBox1 = QGroupBox(self.form1_a) self.groupBox1.setObjectName('groupBox1') self.groupBox1.setTitle('图片显示:') self.graphicsView = QGraphicsView(self.groupBox1) self.graphicsView.setObjectName('graphicsView') # 显示图片信息框 self.textEdit1 = QTextEdit(self.form1_a) self.textEdit1.setObjectName('textEdit1') self.textEdit1.setReadOnly(True) self.textEdit1.setText('当前还没加载图片,' + '\n' + '无法查看图片信息!!!') self.form2_a = QWidget(self.imageLoadingForm) self.form2_a.setObjectName('form2_a') self.groupBox2 = QGroupBox(self.form2_a) self.groupBox2.setObjectName('groupBox2') self.groupBox2.setTitle('图片列表') # 加载图片列表 self.imageListWidget = QListWidget(self.form2_a) self.imageListWidget.setObjectName('imageListWidget') self.imageListWidget.setToolTip('图片加载列表') self.imageListWidget.setMinimumWidth(600) self.buttonWidget = QWidget() self.buttonWidget.setObjectName('buttonWidget') self.imageOpenBtn = QPushButton('打开图片') self.imageOpenBtn.setObjectName('imageOpenBtn') self.imageOpenBtn.clicked.connect(lambda: self.load_image()) # 图片选择改变事件监听 self.imageListWidget.currentRowChanged.connect( lambda: self.image_selecttion_change(self.imageListWidget. currentItem().text())) self.imageListWidget.currentItemChanged.connect( lambda: self.display_image_message(self.imageListWidget. currentItem().text())) # 工具栏 self.imageToolFrame = QFrame(self.form2_a) self.imageToolFrame.setObjectName('imageToolFrame') self.imageToolFrame.setFrameShape(QFrame.StyledPanel) # 开始识别按钮 self.startIdentifyBtn = QPushButton('开始识别') self.startIdentifyBtn.setObjectName('startIdentifyBtn') # ###################################################### # **********文档加载模式UI设计*********** self.textLoadingForm = QWidget(self.loadingFrame) # self.textLoadingForm.setObjectName('textLoadingForm') # # self.form1_b = QWidget(self.textLoadingForm) # self.form1_b.setObjectName('form1_b') # # 显示文档信息框 # self.textEdit2 = QTextEdit(self.form1_b) # self.textEdit2.setObjectName('textEdit2') # # # 工具栏 # self.toolWidget2 = QWidget() # self.toolWidget2.setObjectName('toolWidget2') # self.textOpenBtn = QPushButton('打开文档') # self.textOpenBtn.setObjectName('textOpenBtn') # ############################################################################ # # ***************右侧****************** self.resultFrame = QFrame() self.resultFrame.setObjectName('resultFrame') self.resultFrame.setFrameShape(QFrame.StyledPanel) # 最小化以及设置按钮管理栏 self.resultFrameBar = QWidget() self.resultFrameBar.setObjectName('resultFrameBar') self.resultFrameBar.resize(self.resultFrame.width(), 20) self.resultFrameSettingBtn = QPushButton(self.loadingFrameBar) self.resultFrameSettingBtn.setObjectName('resultFrameSettingBtn') self.resultFrameSettingBtn.setIcon( QIcon('./image/mainWindowIcon/RightForm1Image/setting.png')) self.resultFrameSettingBtn.setMaximumWidth(30) self.resultFrameMinBtn = QPushButton(self.loadingFrameBar) self.resultFrameMinBtn.setIcon( QIcon('./image/mainWindowIcon/RightForm1Image/min.png')) self.resultFrameMinBtn.setMaximumWidth(30) self.resultFrameMinBtn.clicked.connect(lambda: self.hide_resultframe()) self.resultEdit = QTextEdit() self.resultEdit.setObjectName('resultEdit') # ########################################################################### # 分隔符部件 self.mainSplitter = QSplitter(Qt.Horizontal) self.mainSplitter.setObjectName('mainSplitter') def set_form_layout(self): # 主框体总布局 self.allLayout = QHBoxLayout() self.setLayout(self.allLayout) self.allLayout.addWidget(self.mainSplitter) self.mainSplitter.addWidget(self.loadingFrame) self.mainSplitter.addWidget(self.resultFrame) # 左侧布局 self.loadingFrameLayout = QGridLayout() self.loadingFrame.setLayout(self.loadingFrameLayout) self.loadingFrameLayout.addWidget(self.loadingFrameBar, 0, 0) self.loadingFrameLayout.addWidget(self.loadingTab, 1, 0) # ******************加载图片模式******************** self.imageLoadingFormLayout = QGridLayout() self.imageLoadingForm.setLayout(self.imageLoadingFormLayout) self.imageLoadingFormLayout.addWidget(self.form1_a, 0, 0, 3, 1) self.imageLoadingFormLayout.addWidget(self.form2_a, 3, 0, 2, 1) self.loadingFrameBarLayout = QHBoxLayout() self.loadingFrameBar.setLayout(self.loadingFrameBarLayout) self.loadingFrameBarLayout.setAlignment(Qt.AlignRight) self.loadingFrameBarLayout.addWidget(self.loadingFrameSettingBtn) self.loadingFrameBarLayout.addWidget(self.loadingFrameMinBtn) self.form1Layout = QHBoxLayout() self.form1_a.setLayout(self.form1Layout) self.form1Layout.addWidget(self.groupBox1, 3) self.form1Layout.addWidget(self.textEdit1, 1) self.qHBoxLayout = QHBoxLayout() self.groupBox1.setLayout(self.qHBoxLayout) self.qHBoxLayout.addWidget(self.graphicsView) self.form2Layout = QGridLayout() self.form2_a.setLayout(self.form2Layout) self.form2Layout.addWidget(self.groupBox2, 0, 0, 1, 3) self.form2Layout.addWidget(self.imageToolFrame, 0, 4) self.groupBox2Layout = QHBoxLayout() self.groupBox2.setLayout(self.groupBox2Layout) self.groupBox2Layout.addWidget(self.imageListWidget) self.groupBox2Layout.addWidget(self.buttonWidget) self.buttonWidgetLayout = QGridLayout() self.buttonWidget.setLayout(self.buttonWidgetLayout) self.buttonWidgetLayout.addWidget(self.imageOpenBtn) self.imageToolFrameLayout = QVBoxLayout() self.imageToolFrame.setLayout(self.imageToolFrameLayout) self.imageToolFrameLayout.addWidget(self.startIdentifyBtn) # ******************加载文档模式******************** self.loadingTab.addTab(self.imageLoadingForm, '图片加载智能识别 ') self.loadingTab.addTab(self.textLoadingForm, '文档加载智能识别') # 右侧布局 self.resultFrameBarLayout = QHBoxLayout() self.resultFrameBar.setLayout(self.resultFrameBarLayout) self.resultFrameBarLayout.setAlignment(Qt.AlignRight) self.resultFrameBarLayout.addWidget(self.resultFrameSettingBtn) self.resultFrameBarLayout.addWidget(self.resultFrameMinBtn) self.resultFrameLayout = QGridLayout() self.resultFrame.setLayout(self.resultFrameLayout) self.resultFrameLayout.addWidget(self.resultFrameBar) self.resultFrameLayout.addWidget(self.resultEdit) # ******************************业务逻辑********************************** def load_image(self): """ 将图片加载到图片列表 :return: """ image_path, image_type = QFileDialog.getOpenFileName( self, '选择图片', 'c:\\', 'Image files(*.jpg *.gif *.png)') # 增加图片目录 self.imageListWidget.addItem(image_path) # 显示图片 self.display_image(image_path) # self.display_image_message(image_path) def display_image(self, image_path): """ 显示图片 :param image_path: :return: """ self.image_path = image_path self.image = QPixmap() self.image.load(self.image_path) self.graphicsView.scene = QGraphicsScene() item = QGraphicsPixmapItem(self.image) self.graphicsView.scene.addItem(item) self.graphicsView.setScene(self.graphicsView.scene) def image_selecttion_change(self, current_path): self.current_path = current_path self.display_image(self.current_path) # self.display_image_message(self.current_path) def display_image_message(self, image_path): message = '' self.image_path = image_path message = self.load_image_message(self.image_path) self.textEdit1.setText(message) def load_image_message(self, image_path): """ 会返回一个字典,包含图像的各种属性信息 :param image_path: :return: """ self.image_path = image_path message = '' image = Image.open(self.image_path) # 还没有完成************** return message def load_text(self): pass def hide_loadframe(self): self.loadingFrame.hide() def hide_resultframe(self): self.resultFrame.hide()
def HLine(parent): widget = QFrame(parent) widget.setFrameShape(QFrame.HLine) widget.setFrameShadow(QFrame.Sunken) return widget
class Ui_MainWindow(object): def setupUi(self, MainWindow): self.conn = pymysql.connect( host='127.0.0.1', port=3306, user='******', password='******', db='person', charset='utf8', ) self.cur = self.conn.cursor() self.sqlstring = "select * from students where " MainWindow.setObjectName("MainWindow") MainWindow.resize(760, 440) # 根据窗口的大小固定大小 这里相当于设置全屏 MainWindow.setFixedSize(MainWindow.width(), MainWindow.height()) self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.frame = QFrame(self.centralwidget) self.frame.setGeometry(QtCore.QRect(10, 10, 491, 121)) self.frame.setFrameShape(QFrame.StyledPanel) self.frame.setFrameShadow(QFrame.Raised) self.frame.setObjectName("frame") self.check_Sid = QCheckBox(self.frame) self.check_Sid.setGeometry(QtCore.QRect(20, 10, 71, 16)) self.check_Sid.setObjectName("check_Sid") self.check_Sage = QCheckBox(self.frame) self.check_Sage.setGeometry(QtCore.QRect(20, 70, 71, 16)) self.check_Sage.setObjectName("check_Sage") self.check_Sname = QCheckBox(self.frame) self.check_Sname.setGeometry(QtCore.QRect(20, 40, 71, 16)) self.check_Sname.setObjectName("check_Sname") self.check_Ssex = QCheckBox(self.frame) self.check_Ssex.setGeometry(QtCore.QRect(20, 100, 71, 16)) self.check_Ssex.setObjectName("check_Ssex") self.Sid = QLineEdit(self.frame) self.Sid.setGeometry(QtCore.QRect(90, 10, 113, 16)) self.Sid.setObjectName("Sid") self.Sname = QLineEdit(self.frame) self.Sname.setGeometry(QtCore.QRect(90, 40, 113, 16)) self.Sname.setObjectName("Sname") self.first_Sage = QLineEdit(self.frame) self.first_Sage.setGeometry(QtCore.QRect(90, 70, 41, 16)) self.first_Sage.setObjectName("first_Sage") self.Ssex = QLineEdit(self.frame) self.Ssex.setGeometry(QtCore.QRect(90, 100, 113, 16)) self.Ssex.setObjectName("Ssex") self.label = QLabel(self.frame) self.label.setGeometry(QtCore.QRect(140, 70, 16, 16)) self.label.setObjectName("label") self.last_Sage = QLineEdit(self.frame) self.last_Sage.setGeometry(QtCore.QRect(160, 70, 41, 16)) self.last_Sage.setObjectName("last_Sage") self.check_Sdept = QCheckBox(self.frame) self.check_Sdept.setGeometry(QtCore.QRect(270, 40, 71, 16)) self.check_Sdept.setObjectName("check_Sdept") self.Sdept = QLineEdit(self.frame) self.Sdept.setGeometry(QtCore.QRect(340, 40, 113, 16)) self.Sdept.setObjectName("Sdept") self.Sclass = QLineEdit(self.frame) self.Sclass.setGeometry(QtCore.QRect(340, 10, 113, 16)) self.Sclass.setObjectName("Sclass") self.check_Sclass = QCheckBox(self.frame) self.check_Sclass.setGeometry(QtCore.QRect(270, 10, 71, 16)) self.check_Sclass.setObjectName("check_Sclass") self.Saddr = QLineEdit(self.frame) self.Saddr.setGeometry(QtCore.QRect(340, 70, 113, 16)) self.Saddr.setObjectName("Saddr") self.check_Saddr = QCheckBox(self.frame) self.check_Saddr.setGeometry(QtCore.QRect(270, 70, 71, 16)) self.check_Saddr.setObjectName("check_Saddr") self.find = QPushButton(self.frame) self.find.setGeometry(QtCore.QRect(380, 100, 75, 21)) self.find.setObjectName("find") self.find.clicked.connect(self.find_btn) self.sql_out = QTextBrowser(self.centralwidget) self.sql_out.setGeometry(QtCore.QRect(10, 140, 740, 61)) self.sql_out.setObjectName("sql_out") self.result_out = QTableWidget(self.centralwidget) self.result_out.setEditTriggers( QAbstractItemView.NoEditTriggers) # 不可编辑表格 self.result_out.setGeometry(QtCore.QRect(10, 210, 740, 171)) self.result_out.setObjectName("result_out") self.result_out.setColumnCount(7) self.result_out.setRowCount(10) self.result_out.resizeColumnsToContents() self.result_out.resizeRowsToContents() item = QTableWidgetItem() self.result_out.setHorizontalHeaderItem(0, item) item = QTableWidgetItem() self.result_out.setHorizontalHeaderItem(1, item) item = QTableWidgetItem() self.result_out.setHorizontalHeaderItem(2, item) item = QTableWidgetItem() self.result_out.setHorizontalHeaderItem(3, item) item = QTableWidgetItem() self.result_out.setHorizontalHeaderItem(4, item) item = QTableWidgetItem() self.result_out.setHorizontalHeaderItem(5, item) item = QTableWidgetItem() self.result_out.setHorizontalHeaderItem(6, item) self.result_out.horizontalHeader().setDefaultSectionSize(100) self.result_out.horizontalHeader().setMinimumSectionSize(25) self.result_out.verticalHeader().setDefaultSectionSize(30) self.pushButton_2 = QPushButton(self.centralwidget) self.pushButton_2.setGeometry(QtCore.QRect(675, 390, 75, 21)) self.pushButton_2.setObjectName("pushButton_2") self.pushButton_2.clicked.connect(self.p2_clicked) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 509, 23)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def p2_clicked(self): self.pyqt_clicked1.emit() def find_btn(self): self.pyqt_clicked2.emit() def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) self.check_Sid.setText(_translate("MainWindow", "学号", None)) self.check_Sage.setText(_translate("MainWindow", "年龄自", None)) self.check_Sname.setText(_translate("MainWindow", "姓名", None)) self.check_Ssex.setText(_translate("MainWindow", "性别", None)) self.label.setText(_translate("MainWindow", "到", None)) self.check_Sdept.setText(_translate("MainWindow", "系", None)) self.check_Sclass.setText(_translate("MainWindow", "班级", None)) self.check_Saddr.setText(_translate("MainWindow", "地址", None)) self.find.setText(_translate("MainWindow", "查询", None)) self.sql_out.setText(self.sqlstring) item = self.result_out.horizontalHeaderItem(0) item.setText(_translate("MainWindow", "Sid", None)) item = self.result_out.horizontalHeaderItem(1) item.setText(_translate("MainWindow", "Sname ", None)) item = self.result_out.horizontalHeaderItem(2) item.setText(_translate("MainWindow", "Sage", None)) item = self.result_out.horizontalHeaderItem(3) item.setText(_translate("MainWindow", "Ssex", None)) item = self.result_out.horizontalHeaderItem(4) item.setText(_translate("MainWindow", "Sclass", None)) item = self.result_out.horizontalHeaderItem(5) item.setText(_translate("MainWindow", "Sdept", None)) item = self.result_out.horizontalHeaderItem(6) item.setText(_translate("MainWindow", "Saddr", None)) self.pushButton_2.setText(_translate("MainWindow", "退出", None)) def mousePressEvent(self, event): # if event.KeyWord == Qt.LeftButton: print("nihao") def buttonTest(self): temp_sqlstring = self.sqlstring is_first = True if self.check_Sid.isChecked(): mystr = self.Sid.text() if is_first: is_first = False if mystr.find("%") == -1: temp_sqlstring += "Sid = '" + self.Sid.text() + "'" else: temp_sqlstring += "Sid like '" + self.Sid.text() + "'" else: if mystr.find("%") == -1: temp_sqlstring += " and Sid = '" + self.Sid.text() + "'" else: temp_sqlstring += " and Sid like '" + self.Sid.text() + "'" if self.check_Sname.isChecked(): if is_first: mystr = self.Sname.text() is_first = False if mystr.find("%") == -1: temp_sqlstring += "Sname = '" + self.Sname.text() + "'" else: temp_sqlstring += "Sname like '" + self.Sname.text() + "'" else: if mystr.find("%") == -1: temp_sqlstring += " and Sname = '" + self.Sname.text( ) + "'" else: temp_sqlstring += " and Sname like '" + self.Sname.text( ) + "'" if self.check_Sage.isChecked(): if is_first: is_first = False temp_sqlstring += "Sage >= " + self.first_Sage.text() + \ " and Sage <= " + self.last_Sage.text() else: temp_sqlstring += " and Sage >= " + self.first_Sage.text() + \ " and Sage <= " + self.last_Sage.text() if self.check_Ssex.isChecked(): if is_first: is_first = False temp_sqlstring += "Ssex = '" + self.Ssex.text() + "'" else: temp_sqlstring += " and Ssex = '" + self.Ssex.text() + "'" if self.check_Sclass.isChecked(): if is_first: mystr = self.Sclass.text() is_first = False if mystr.find("%") == -1: temp_sqlstring += "Sclass = '" + self.Sclass.text() + "'" else: temp_sqlstring += "Sclass like '" + self.Sclass.text( ) + "'" else: if mystr.find("%") == -1: temp_sqlstring += " and Sclass = '" + self.Sclass.text( ) + "'" else: temp_sqlstring += " and Sclass like '" + self.Sclass.text( ) + "'" if self.check_Sdept.isChecked(): if is_first: mystr = self.Sdept.text() is_first = False if mystr.find("%") == -1: temp_sqlstring += "Sdept = '" + self.Sdept.text() + "'" else: temp_sqlstring += "Sdept like '" + self.Sdept.text() + "'" else: if mystr.find("%") == -1: temp_sqlstring += " and Sdept = '" + self.Sdept.text( ) + "'" else: temp_sqlstring += " and Sdept like '" + self.Sdept.text( ) + "'" if self.check_Saddr.isChecked(): if is_first: mystr = self.Saddr.text() is_first = False if mystr.find("%") == -1: temp_sqlstring += "Saddr = '" + self.Saddr.text() + "'" else: temp_sqlstring += " and Saddr like '" + self.Saddr.text( ) + "'" else: if mystr.find("%") == -1: temp_sqlstring += " and Saddr = '" + self.Saddr.text( ) + "'" else: temp_sqlstring += " and Saddr like '" + self.Saddr.text( ) + "'" self.result_out.clearContents() # 每一次查询时清除表格中信息 if not (is_first): print(temp_sqlstring) self.cur.execute(temp_sqlstring) k = 0 for i in self.cur: print("----------", i) w = 0 for j in i: # 这里是将int类型转成string类型,方便后面文本设置 if type(j) == int: newItem = QTableWidgetItem(str(j)) else: newItem = QTableWidgetItem(j) # 根据循环标签一次对table中的格子进行设置 self.result_out.setItem(k, w, newItem) w += 1 k += 1 self.sql_out.setText("") self.sql_out.append(temp_sqlstring) print("find button pressed") def buttonExit(self): self.conn.commit() self.cur.close() self.conn.close() self.close() def keyPressEvent(self, e): if e.key() == QtCore.Qt.Key_Escape: self.buttonExit()
def ctrl_layout_add_separator(): line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) ctrl_layout.addWidget(line)
def init_ui(self): self.setFont(QFont('Segoe UI')) grid_layout = QGridLayout() grid_layout.setSpacing(10) grid_layout.setContentsMargins(0, 0, 0, 0) self.setGeometry(0, 0, 400, 600) qtRectangle = self.frameGeometry() screen = QApplication.desktop().screenNumber( QApplication.desktop().cursor().pos()) centerPoint = QApplication.desktop().screenGeometry(screen).center() qtRectangle.moveCenter(centerPoint) self.move(qtRectangle.topLeft()) self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground) self.setWindowTitle('Hydro Apps') self.showNormal() x_close = QPushButton(' x ') x_close.setProperty('close', True) x_close.setFont(QFont('Verdana')) x_close.clicked.connect(self.close_app) x_close.setToolTip('Close') minimise = QPushButton(' - ') minimise.setProperty('close', True) minimise.setFont(QFont('Verdana')) minimise.clicked.connect(self.min_app) minimise.setToolTip('Minimise') header_logo = QLabel() header_logo.setPixmap( QPixmap(':/assets/2dropsshadow.ico').scaled( 32, 32, Qt.KeepAspectRatio)) header_label = QLabel(' Hydro Applications') header_label.setProperty('headertext', True) header_frame = QFrame() header_frame.setProperty('headerframe', True) docalc_label = QLabel('DO Calculator') docalc_launch = QPushButton('Launch DO Calc') docalc_launch.clicked.connect(self.open_docalc) docalc_label.setToolTip( 'The DO Calculator can reprocess results and format the results for HyLIMS upload.' ) linesep1 = QFrame() linesep1.setFrameShape(QFrame.HLine) linesep1.setFrameShadow(QFrame.Sunken) dataqc_label = QLabel('Hydrology Data QCer') dataqc_launch = QPushButton('Launch QCer') dataqc_launch.clicked.connect(self.open_dataqc) linesep2 = QFrame() linesep2.setFrameShape(QFrame.HLine) linesep2.setFrameShadow(QFrame.Sunken) qctable_label = QLabel('QC Table Stats') qctable_launch = QPushButton('Launch QCTab Stats') qctable_launch.clicked.connect(self.open_qctable) qctable_launch.setFixedWidth(160) baseline_label = QLabel('Base Offset Plotter') baseline_launch = QPushButton('Launch BO Plotter') baseline_launch.clicked.connect(self.open_boplot) iodate_label = QLabel('Analyte Normality') iodate_launch = QPushButton('Launch Analyte Norm') iodate_launch.clicked.connect(self.open_ionorm) glasscal_label = QLabel('Glass Calibration') glasscal_launch = QPushButton('Launch Glass Cal') glasscal_launch.clicked.connect(self.open_glasscal) nccheck_label = QLabel('NC Checker') nccheck_launch = QPushButton('Launch NC Checker') nccheck_launch.clicked.connect(self.open_nccheck) time_stamp_label = QLabel('SLK Time Stamps') time_stamp_launch = QPushButton('Launch Stamp Gen') time_stamp_launch.clicked.connect(self.open_time_gen) smooth_bin_label = QLabel('Smooth Bins') smooth_bin_launch = QPushButton('Launch Smooth Bins') smooth_bin_launch.clicked.connect(self.open_smooth_bin) linesep3 = QFrame() linesep3.setFrameShape(QFrame.HLine) linesep3.setFrameShadow(QFrame.Sunken) linesep4 = QFrame() linesep4.setFrameShape(QFrame.HLine) linesep4.setFrameShadow(QFrame.Sunken) linesep5 = QFrame() linesep5.setFrameShape(QFrame.HLine) linesep5.setFrameShadow(QFrame.Sunken) linesep6 = QFrame() linesep6.setFrameShape(QFrame.HLine) linesep6.setFrameShadow(QFrame.Sunken) linesep7 = QFrame() linesep7.setFrameShape(QFrame.HLine) linesep7.setFrameShadow(QFrame.Sunken) linesep8 = QFrame() linesep8.setFrameShape(QFrame.HLine) linesep8.setFrameShadow(QFrame.Sunken) window_surround = QFrame() window_surround.setProperty('bg', True) close = QPushButton('Close') close.clicked.connect(self.close_app) close.setFixedWidth(125) grid_layout.addWidget(window_surround, 0, 0, 22, 4) grid_layout.addWidget(header_frame, 1, 1, 2, 2) grid_layout.addWidget(header_logo, 1, 1, 2, 1, Qt.AlignHCenter) grid_layout.addWidget(header_label, 1, 1, 2, 2, Qt.AlignHCenter) #grid_layout.addWidget(body_frame, 1, 0, 5, 2) grid_layout.addWidget(docalc_label, 4, 1) grid_layout.addWidget(docalc_launch, 4, 2) grid_layout.addWidget(linesep1, 5, 1, 1, 2) grid_layout.addWidget(qctable_label, 6, 1) grid_layout.addWidget(qctable_launch, 6, 2) grid_layout.addWidget(linesep2, 7, 1, 1, 2) grid_layout.addWidget(dataqc_label, 8, 1) grid_layout.addWidget(dataqc_launch, 8, 2) grid_layout.addWidget(linesep3, 9, 1, 1, 2) grid_layout.addWidget(baseline_label, 10, 1) grid_layout.addWidget(baseline_launch, 10, 2) grid_layout.addWidget(linesep4, 11, 1, 1, 2) grid_layout.addWidget(iodate_label, 12, 1) grid_layout.addWidget(iodate_launch, 12, 2) grid_layout.addWidget(linesep5, 13, 1, 1, 2) grid_layout.addWidget(glasscal_label, 14, 1) grid_layout.addWidget(glasscal_launch, 14, 2) grid_layout.addWidget(linesep6, 15, 1, 1, 2) grid_layout.addWidget(nccheck_label, 16, 1) grid_layout.addWidget(nccheck_launch, 16, 2) grid_layout.addWidget(linesep7, 17, 1, 1, 2) grid_layout.addWidget(time_stamp_label, 18, 1) grid_layout.addWidget(time_stamp_launch, 18, 2) grid_layout.addWidget(linesep8, 19, 1, 1, 2) grid_layout.addWidget(smooth_bin_label, 20, 1) grid_layout.addWidget(smooth_bin_launch, 20, 2) #grid_layout.addWidget(close, 15, 1, 1, 2, Qt.AlignHCenter) dialog_buttons_layout = QHBoxLayout() grid_layout.addLayout(dialog_buttons_layout, 0, 2, Qt.AlignBottom | Qt.AlignRight) dialog_buttons_layout.addWidget(minimise) dialog_buttons_layout.addWidget(x_close) #grid_layout.addWidget(x_close, 0, 3, Qt.AlignLeft | Qt.AlignBottom) #grid_layout.addWidget(__min, 0, 2, Qt.AlignLeft | Qt.AlignBottom) self.centralWidget().setLayout(grid_layout) self.show()