def __init__(self, snk, parent=None): QtWidgets.QWidget.__init__(self, parent) self.setWindowTitle('Control Panel') self.snk = snk self.setToolTip('Control the signals') QtWidgets.QToolTip.setFont(Qt.QFont('OldEnglish', 10)) self.layout = QtWidgets.QFormLayout(self) # Control the first signal self.freq1Edit = QtWidgets.QLineEdit(self) self.freq1Edit.setMinimumWidth(100) self.layout.addRow("Sine Frequency:", self.freq1Edit) self.freq1Edit.editingFinished.connect(self.freq1EditText) self.amp1Edit = QtWidgets.QLineEdit(self) self.amp1Edit.setMinimumWidth(100) self.layout.addRow("Sine Amplitude:", self.amp1Edit) self.amp1Edit.editingFinished.connect(self.amp1EditText) # Control the second signal self.amp2Edit = QtWidgets.QLineEdit(self) self.amp2Edit.setMinimumWidth(100) self.layout.addRow("Noise Amplitude:", self.amp2Edit) self.amp2Edit.editingFinished.connect(self.amp2EditText) # Control the histogram self.hist_npts = QtWidgets.QLineEdit(self) self.hist_npts.setMinimumWidth(100) self.hist_npts.setValidator(Qt.QIntValidator(0, 8191)) self.hist_npts.setText("{0}".format(self.snk.nsamps())) self.layout.addRow("Number of Points:", self.hist_npts) self.hist_npts.editingFinished.connect(self.set_nsamps) self.hist_bins = QtWidgets.QLineEdit(self) self.hist_bins.setMinimumWidth(100) self.hist_bins.setValidator(Qt.QIntValidator(0, 1000)) self.hist_bins.setText("{0}".format(self.snk.bins())) self.layout.addRow("Number of Bins:", self.hist_bins) self.hist_bins.editingFinished.connect(self.set_bins) self.hist_auto = QtWidgets.QPushButton("scale", self) self.layout.addRow("Autoscale X:", self.hist_auto) self.hist_auto.pressed.connect(self.autoscalex) self.quit = QtWidgets.QPushButton('Close', self) self.quit.setMinimumWidth(100) self.layout.addWidget(self.quit) self.quit.clicked.connect(QtWidgets.qApp.quit)
def __init__(self): super().__init__() self.setGeometry(540, 65, 320, 200) self.setWindowTitle('MainWindow') self.labelMain = Qt.QLabel("Результат потоковой задачи WorkThreadMain: ") self.labelThread = Qt.QLabel("Результат Потоковой задачи WorkThread: ") validator = Qt.QIntValidator(1, 999, self) validator.setBottom(1) self.lineEdit = Qt.QLineEdit() self.lineEdit.setPlaceholderText("Начильный параметр для потоковой задачи WorkThread") # self.lineEdit будет принимать только целые числа от 1 до 999 self.lineEdit.setValidator(validator) self.btn = Qt.QPushButton("Start поток WorkThread") self.btn.clicked.connect(self.on_btn) self.btnMain = Qt.QPushButton("Запустить поток WorkThreadMain") self.btnMain.clicked.connect(self.on_btnMain) layout = Qt.QVBoxLayout(self) layout.addWidget(self.labelMain) layout.addWidget(self.labelThread) layout.addWidget(self.lineEdit) layout.addWidget(self.btn) layout.addWidget(self.btnMain) self.msg = MsgBox() self.thread = None self.threadMain = None
def __init__(self, parent=None, bottom=None, top=None): super(IntLineEdit, self).__init__(parent) validator = Qt.QIntValidator(self) if bottom is not None: validator.setBottom(bottom) if top is not None: validator.setTop(top) self.setValidator(validator) self.editingFinished.connect(self._cleanDisplayedValue)
def get_numeric_validator(self, property, type): if type == 'Float': validator = Qt.QDoubleValidator() if property in self.RANGE_HINTS: min, max, decimals = self.RANGE_HINTS[property] else: min, max, decimals = FLOAT_MIN, FLOAT_MAX, FLOAT_DECIMALS if decimals is not None: validator.setDecimals(decimals) if type == 'Int': validator = Qt.QIntValidator() if property in self.RANGE_HINTS: min, max = self.RANGE_HINTS[property] else: min, max = INT_MIN, INT_MAX if min is not None: validator.setBottom(min) if max is not None: validator.setTop(max) return validator
def make_numeric_widget(self, prop, prop_data): andor_type = prop_data['andor_type'] if andor_type == 'Float': validator = Qt.QDoubleValidator() coerce_type = float else: # andor_type == 'Int' validator = Qt.QIntValidator() coerce_type = int widget = Qt.QLineEdit() widget.setValidator(validator) def receive_update(value): widget.setText(f'{value:.6g}') update = self.subscribe(self.PROPERTY_ROOT + prop, callback=receive_update) if update is None: raise TypeError('{} is not a writable property!'.format(prop)) def editing_finished(): try: value = coerce_type(widget.text()) update(value) except ValueError as e: # from the coercion Qt.QMessageBox.warning(self, 'Invalid Value', e.args[0]) except rpc_client.RPCError as e: # from the update if e.args[0].find('OUTOFRANGE') != -1: valid_min, valid_max = getattr(self.scope.camera, prop+'_range') if value < valid_min: update(valid_min) elif value > valid_max: update(valid_max) else: if e.args[0].find('NOTWRITABLE') != -1: error = 'Given the camera state, {} is not modifiable.'.format(prop) else: error = 'Could not set {} ({}).'.format(prop, e.args[0]) Qt.QMessageBox.warning(self, 'Invalid Value', error) widget.editingFinished.connect(editing_finished) return widget
def _curveTypeBox(self): box = Qt.QGroupBox(title="Curve Info") self.curveInfoBox = box lo = Qt.QHBoxLayout() lab = Qt.QLabel("Curve Type", self) lo.addWidget(lab) self.curveTypesSelector = self._curvesComboBox() lo.addWidget(self.curveTypesSelector) self.polyLabel = Qt.QLabel("Polynomial Order:") self.polyOrderBox = Qt.QLineEdit("3") orderVal = Qt.QIntValidator() orderVal.setBottom(0) self.polyOrderBox.setValidator(orderVal) self.polyOrderBox.textChanged.connect(self._polyOrderChanged) if self.getCurveTypeIndex() == 1: lo.addWidget(self.polyLabel) lo.addWidget(self.polyOrderBox) box.setLayout(lo) return box
def initUI(self): """ This function defines the architecture of the GUI and connects the created QT widgets to the corresponding functions defined in this file. The various QT objects are arranged along vertical and horizontal axes. """ self.subwindow_color_map_settings_bl = manual_input_color_map.ColorMapSettingsView( self, 'bl') self.subwindow_color_map_settings_rm = manual_input_color_map.ColorMapSettingsView( self, 'rm') self.subwindow_color_rgb_bl = manual_input_color_map.InputColorRGB( self, 'bl') self.subwindow_color_rgb_rm = manual_input_color_map.InputColorRGB( self, 'rm') self.subwindow_lookup_table_bl = manual_input_lookup_table.TableView( self, 'bl') self.subwindow_lookup_table_rm = manual_input_lookup_table.TableView( self, 'rm') self.label_placeholder = Qt.QLabel() self.button_load_mha_files = Qt.QPushButton('Load .mha files', self) self.button_load_mha_files.clicked.connect(partial(loadMHA, self)) self.button_load_mdf_file = Qt.QPushButton('Load .mdf file', self) self.button_load_mdf_file.clicked.connect(partial(loadMDF, self)) self.label_frame_rate = Qt.QLabel(self) self.label_frame_rate.setText("Frame rate: ") self.label_frame_rate_display = Qt.QLabel(self) self.label_frame_rate_display.setText("0.00") self.label_frame_rate_display.setStyleSheet( "background-color: rgba(255, 255, 255, 100%)") self.label_image_count = Qt.QLabel(self) self.label_image_count.setText("Image #: ") self.label_image_count_display = Qt.QLabel(self) self.label_image_count_display.setText("- / -") self.label_image_count_display.setStyleSheet( "background-color: rgba(255, 255, 255, 100%)") self.button_saving_directory_screenshots = Qt.QPushButton( 'Choose screenshot directory', self) self.button_saving_directory_screenshots.clicked.connect( partial(setScreenshotSaveDirectory, self)) self.checkbox_rm_buildup = Qt.QCheckBox("Roadmap build-up", self) self.checkbox_rm_buildup.setChecked(True) self.checkbox_rm_buildup.stateChanged.connect( partial(checkboxShowRoadmap, self)) self.checkbox_FOV = Qt.QCheckBox("Show FOV", self) self.checkbox_FOV.setChecked(False) self.checkbox_FOV.stateChanged.connect(partial(checkboxFOVFunction, self)) self.checkbox_camera_specifications = Qt.QCheckBox( "Show camera specifications", self) self.checkbox_camera_specifications.setChecked(True) self.checkbox_camera_specifications.stateChanged.connect( partial(checkboxCameraSpecifications, self)) self.button_save_rm = Qt.QPushButton('Save roadmap') self.button_save_rm.clicked.connect(partial(saveRoapmap, self)) self.checkbox_save_images = Qt.QCheckBox("Save screenshots", self) self.checkbox_save_images.setChecked(False) self.checkbox_save_images.stateChanged.connect( partial(screenshotAndSave, self)) self.button_start_stop = Qt.QPushButton('', self) self.button_start_stop.setCheckable(True) self.button_start_stop.setIcon(self.style().standardIcon( Qt.QStyle.SP_MediaPlay)) self.button_start_stop.clicked[bool].connect(partial(pauseAndPlay, self)) self.button_next_image = Qt.QPushButton('', self) self.button_next_image.setIcon(self.style().standardIcon( Qt.QStyle.SP_MediaSkipForward)) self.button_next_image.clicked.connect(partial(showNextImage, self)) self.button_previous_image = Qt.QPushButton('', self) self.button_previous_image.setIcon(self.style().standardIcon( Qt.QStyle.SP_MediaSkipBackward)) self.button_previous_image.clicked.connect(partial(showPreviousImage, self)) self.label_th_slider = Qt.QLabel(self) self.label_th_slider.setText("Threshold") self.label_th_slider.setFixedWidth(125) self.slider_intervall_ramp_rm = Qt.QSlider(self) self.slider_intervall_ramp_rm.setMinimum(1) self.slider_intervall_ramp_rm.setMaximum(10000) self.slider_intervall_ramp_rm.setProperty("value", 10000 * self.sl_pos_ri_rm) self.slider_intervall_ramp_rm.setOrientation(QtCore.Qt.Horizontal) self.slider_intervall_ramp_rm.setObjectName("slider_intervall_ramp_rm") self.slider_intervall_ramp_rm.valueChanged.connect( partial(functionSliderRampIntervallRm, self)) self.slider_intervall_ramp_bl = Qt.QSlider(self) self.slider_intervall_ramp_bl.setMinimum(1) self.slider_intervall_ramp_bl.setMaximum(10000) self.slider_intervall_ramp_bl.setProperty("value", 10000 * self.sl_pos_ri_bl) self.slider_intervall_ramp_bl.setOrientation(QtCore.Qt.Horizontal) self.slider_intervall_ramp_bl.setObjectName("slider_th_bl") self.slider_intervall_ramp_bl.valueChanged.connect( partial(functionSliderRampIntervallBl, self)) self.slider_th_rm = Qt.QSlider(self) self.slider_th_rm.setMaximum(100) self.slider_th_rm.setProperty("value", 100 * self.sl_pos_th_rm) self.slider_th_rm.setOrientation(QtCore.Qt.Horizontal) self.slider_th_rm.setObjectName("slider_th_bl") self.slider_th_rm.valueChanged.connect(partial(functionSliderThRm, self)) self.slider_th_bl = Qt.QSlider(self) self.slider_th_bl.setMaximum(100) self.slider_th_bl.setProperty("value", 100 * self.sl_pos_th_bl) self.slider_th_bl.setOrientation(QtCore.Qt.Horizontal) self.slider_th_bl.setObjectName("slider_th_bl") self.slider_th_bl.valueChanged.connect(partial(functionSliderThBl, self)) self.label_op_slider = Qt.QLabel(self) self.label_op_slider.setText("Opacity") self.label_op_slider.setFixedWidth(125) self.label_intervall_ramp_ramp = Qt.QLabel(self) self.label_intervall_ramp_ramp.setText("Intervall ramp") self.label_intervall_ramp_ramp.setFixedWidth(125) self.slider_op_bl = Qt.QSlider(self) self.slider_op_bl.setMaximum(100) self.slider_op_bl.setProperty("value", 100 * self.sl_pos_op_bl) self.slider_op_bl.setOrientation(QtCore.Qt.Horizontal) self.slider_op_bl.setObjectName("slider_op_bl") self.slider_op_bl.valueChanged.connect(partial(functionSliderOpBl, self)) self.slider_op_rm = Qt.QSlider(self) self.slider_op_rm.setMaximum(100) self.slider_op_rm.setProperty("value", 100 * self.sl_pos_op_rm) self.slider_op_rm.setOrientation(QtCore.Qt.Horizontal) self.slider_op_rm.setObjectName("slider_op_rm") self.slider_op_rm.valueChanged.connect(partial(functionSliderOpRm, self)) self.label_playback_speed = Qt.QLabel(self) self.label_playback_speed.setText("Playback Speed") self.label_playback_speed.setFixedWidth(125) self.slider_playback_speed = Qt.QSlider(self) self.slider_playback_speed.setMaximum(500) self.slider_playback_speed.setProperty("value", round(self.t_ms)) self.slider_playback_speed.setOrientation(QtCore.Qt.Horizontal) self.slider_playback_speed.setObjectName("slider_playback_speed") self.slider_playback_speed.setTickInterval(21.5) self.slider_playback_speed.setTickPosition(Qt.QSlider.TicksBelow) self.slider_playback_speed.valueChanged.connect( partial(setPlaybackSpeed1, self)) self.button_activate_manual_lookup_table_bl = Qt.QPushButton('', self) self.button_activate_manual_lookup_table_bl.setText( "Define lookup table bolus") self.button_activate_manual_lookup_table_bl.\ clicked.connect( partial(manualLookupTablebl, self) ) self.button_activate_manual_lookup_table_rm = Qt.QPushButton('', self) self.button_activate_manual_lookup_table_rm.setText( "Define lookup table roadmap") self.button_activate_manual_lookup_table_rm.\ clicked.connect( partial(manualLookupTablerm, self) ) self.label_camera_operations = Qt.QLabel() self.label_camera_operations.setText("Manual camera control") self.label_camera_operations.setStyleSheet('color: grey') self.label_camera_operations.setWordWrap(True) self.label_camera_operations.setAlignment(Qt.Qt.AlignCenter) self.label_manual_defintion_lookup_table = Qt.QLabel() self.label_manual_defintion_lookup_table.setText("Manual definition") self.label_manual_defintion_lookup_table.setWordWrap(True) self.label_text_above_bl_slider = Qt.QLabel() self.label_text_above_bl_slider.setText("Bolus") self.label_text_above_bl_slider.setStyleSheet('color: grey') self.label_text_above_bl_slider.setAlignment(Qt.Qt.AlignCenter) self.label_text_above_rm_slider = Qt.QLabel() self.label_text_above_rm_slider.setText("Roadmap") self.label_text_above_rm_slider.setStyleSheet('color: grey') self.label_text_above_rm_slider.setAlignment(Qt.Qt.AlignCenter) self.label_text_above_image_data = Qt.QLabel() self.label_text_above_image_data.setText("Image data") self.label_text_above_image_data.setStyleSheet('color: grey') self.label_text_above_image_data.setAlignment(Qt.Qt.AlignCenter) self.label_text_above_playback_settings = Qt.QLabel() self.label_text_above_playback_settings.setText("Playback control") self.label_text_above_playback_settings.setStyleSheet('color: grey') self.label_text_above_playback_settings.setWordWrap(True) self.label_text_above_playback_settings.setAlignment(Qt.Qt.AlignCenter) self.lineedit_interpolation_dim_x = Qt.QLineEdit(self) self.validator_lineedit_interpolation_dim_x = Qt.QIntValidator() self.lineedit_interpolation_dim_x.setPlaceholderText('x') self.lineedit_interpolation_dim_x.setValidator( self.validator_lineedit_interpolation_dim_x) self.lineedit_interpolation_dim_y = Qt.QLineEdit(self) self.validator_lineedit_interpolation_dim_y = Qt.QIntValidator() self.lineedit_interpolation_dim_y.setPlaceholderText('y') self.lineedit_interpolation_dim_y.setValidator( self.validator_lineedit_interpolation_dim_y) self.lineedit_interpolation_dim_z = Qt.QLineEdit(self) self.validator_lineedit_interpolation_dim_z = Qt.QIntValidator() self.lineedit_interpolation_dim_z.setPlaceholderText('z') self.lineedit_interpolation_dim_z.setValidator( self.validator_lineedit_interpolation_dim_z) self.label_x_1 = Qt.QLabel() self.label_x_1.setText('x') self.label_x_1.setAlignment(Qt.Qt.AlignCenter) self.label_x_2 = Qt.QLabel() self.label_x_2.setText('x') self.label_x_2.setAlignment(Qt.Qt.AlignCenter) self.button_set_interpolation_dims = Qt.QPushButton('Dialog', self) self.button_set_interpolation_dims.setCheckable(True) self.button_set_interpolation_dims.clicked[bool].connect( partial(interpolateImageData, self)) self.button_set_interpolation_dims.setText("Activate interpolation") self.button_set_camera_operation = Qt.QPushButton('Dialog', self) self.button_set_camera_operation.clicked.connect( partial(setCameraOperation, self)) self.button_set_camera_operation.setText("SET") self.button_set_amb_diff_spec_rm = Qt.QPushButton('Dialog', self) self.button_set_amb_diff_spec_rm.clicked.connect( partial(setAmbDiffSpec, self, 'rm')) self.button_set_amb_diff_spec_rm.setText("SET") self.button_set_amb_diff_spec_bl = Qt.QPushButton('Dialog', self) self.button_set_amb_diff_spec_bl.clicked.connect( partial(setAmbDiffSpec, self, 'bl')) self.button_set_amb_diff_spec_bl.setText("SET") self.lineedit_camera_control = Qt.QLineEdit(self) self.lineedit_camera_control.setPlaceholderText('x, y, z') self.lineedit_amb_diff_spec_rm = Qt.QLineEdit(self) self.lineedit_amb_diff_spec_rm.setMinimumSize(10, 10) self.lineedit_amb_diff_spec_rm.setSizePolicy(Qt.QSizePolicy.Minimum, Qt.QSizePolicy.Minimum) self.lineedit_amb_diff_spec_bl = Qt.QLineEdit(self) self.lineedit_amb_diff_spec_bl.setMinimumSize(10, 10) self.lineedit_amb_diff_spec_bl.setSizePolicy(Qt.QSizePolicy.Minimum, Qt.QSizePolicy.Minimum) self.label_image_data_size = Qt.QLabel(self) self.label_image_data_size.setText("Current image data size: ") self.label_display_image_data_size = Qt.QLabel(self) self.label_display_image_data_size.setText("-") self.label_display_image_data_size.setStyleSheet( "background-color: rgba(255, 255, 255, 100%)") self.combobox_box_camera = Qt.QComboBox() self.combobox_box_camera.addItem("Set camera position") self.combobox_box_camera.addItem("Set camera focal point") self.combobox_box_camera.addItem("Set rotation angle") self.combobox_box_camera.currentIndexChanged.connect( partial(placeholderTextCameraLineedit, self)) self.combobox_amb_diff_spec = Qt.QComboBox() self.combobox_amb_diff_spec.addItem("Lighting...") self.combobox_amb_diff_spec.addItem("Set Ambient") self.combobox_amb_diff_spec.addItem("Set Diffuse") self.combobox_amb_diff_spec.addItem("Set Specular") self.combobox_amb_diff_spec.model().item(0).setEnabled(False) self.combobox_amb_diff_spec.currentIndexChanged.connect( partial(placeholderLineEditAmbDiffSpec, self, 'rm')) self.combobox_amb_diff_spec.currentIndexChanged.connect( partial(placeholderLineEditAmbDiffSpec, self, 'bl')) self.combobox_color_bl = Qt.QComboBox() self.combobox_color_bl.addItem("Red") self.combobox_color_bl.addItem("Blue") self.combobox_color_bl.addItem("Green") self.combobox_color_bl.addItem("Activate colormap") self.combobox_color_bl.addItem("Enter RGB ...") self.combobox_color_bl.currentIndexChanged.connect( partial(setColor, self, 'bl')) self.combobox_color_rm = Qt.QComboBox() self.combobox_color_rm.addItem("Red") self.combobox_color_rm.addItem("Blue") self.combobox_color_rm.addItem("Green") self.combobox_color_rm.addItem("Activate colormap") self.combobox_color_rm.addItem("Enter RGB ...") self.combobox_color_rm.setCurrentIndex(1) self.combobox_color_rm.activated.connect(partial(setColor, self, 'rm')) self.combobox_pre_image_analysis = Qt.QComboBox() self.combobox_pre_image_analysis.addItem("Pre-image analysis active") self.combobox_pre_image_analysis.addItem("Only max/min") self.combobox_pre_image_analysis.addItem( "Restrict to 100 images (random selection)") self.combobox_pre_image_analysis.addItem("Pre-image analysis deactivated") self.combobox_pre_image_analysis.setCurrentIndex(0) self.combobox_pre_image_analysis.activated.connect( partial(preImageAnalysisSettings, self)) self.label_color = Qt.QLabel(self) self.label_color.setText("Color") self.label_color.setFixedWidth(125) """ The following lines define the spatial relation of the defined QT widgets along horizontal and vertical axes (--> Qt.QHBoxLayout / Qt.QVBoxLayout) """ self.hl_load_buttons = Qt.QHBoxLayout() self.hl_load_buttons.addWidget(self.button_load_mha_files) self.hl_load_buttons.addWidget(self.button_load_mdf_file) self.hl_load_buttons.addWidget(self.button_saving_directory_screenshots) self.hl_load_buttons.addWidget(self.button_save_rm) self.hl_load_buttons.addWidget(self.combobox_pre_image_analysis) self.hl_checkboxes = Qt.QHBoxLayout() self.hl_checkboxes.addWidget(self.checkbox_save_images) self.hl_checkboxes.addWidget(self.checkbox_FOV) self.hl_checkboxes.addWidget(self.checkbox_rm_buildup) self.hl_checkboxes.addWidget(self.checkbox_camera_specifications) self.hl_playback_settings = Qt.QHBoxLayout() self.hl_playback_settings.addWidget(self.label_image_count) self.hl_playback_settings.addWidget(self.label_image_count_display) self.hl_playback_settings.addWidget(self.label_frame_rate) self.hl_playback_settings.addWidget(self.label_frame_rate_display) self.hl_playback_settings.addWidget(self.label_placeholder) self.hl_playback_settings.addWidget(self.button_previous_image) self.hl_playback_settings.addWidget(self.button_start_stop) self.hl_playback_settings.addWidget(self.button_next_image) self.hl_playback_speed = Qt.QHBoxLayout() self.hl_playback_speed.addWidget(self.label_playback_speed) self.hl_playback_speed.addWidget(self.slider_playback_speed) self.grid_camera_operations = Qt.QGridLayout() self.grid_camera_operations.addWidget(self.combobox_box_camera, 1, 1, 1, 3) self.grid_camera_operations.addWidget(self.lineedit_camera_control, 1, 4, 1, 2) self.grid_camera_operations.addWidget(self.button_set_camera_operation, 1, 6, 1, 3) self.hl_manual_lookup_tables = Qt.QHBoxLayout() self.hl_manual_lookup_tables.addWidget( self.button_activate_manual_lookup_table_bl) self.hl_manual_lookup_tables.addWidget( self.button_activate_manual_lookup_table_rm) self.slider_block = Qt.QGridLayout() self.slider_block.addWidget(self.label_text_above_bl_slider, 1, 2, 1, 2) self.slider_block.addWidget(self.label_text_above_rm_slider, 1, 4, 1, 2) self.slider_block.addWidget(self.label_color, 4, 1) self.slider_block.addWidget(self.combobox_color_bl, 4, 2, 2, 2) self.slider_block.addWidget(self.combobox_color_rm, 4, 4, 2, 2) self.slider_block.addWidget(self.label_th_slider, 6, 1) self.slider_block.addWidget(self.slider_th_bl, 6, 2, 2, 2) self.slider_block.addWidget(self.slider_th_rm, 6, 4, 2, 2) self.slider_block.addWidget(self.label_op_slider, 8, 1) self.slider_block.addWidget(self.slider_op_bl, 8, 2, 2, 2) self.slider_block.addWidget(self.slider_op_rm, 8, 4, 2, 2) self.slider_block.addWidget(self.label_intervall_ramp_ramp, 10, 1) self.slider_block.addWidget(self.slider_intervall_ramp_bl, 10, 2, 2, 2) self.slider_block.addWidget(self.slider_intervall_ramp_rm, 10, 4, 2, 2) self.slider_block.addWidget(self.label_manual_defintion_lookup_table, 12, 1) self.slider_block.addWidget(self.button_activate_manual_lookup_table_bl, 12, 2, 1, 2) self.slider_block.addWidget(self.button_activate_manual_lookup_table_rm, 12, 4, 1, 2) self.slider_block.addWidget(self.combobox_amb_diff_spec, 14, 1) self.slider_block.addWidget(self.lineedit_amb_diff_spec_bl, 14, 2, 1, 1) self.slider_block.addWidget(self.button_set_amb_diff_spec_bl, 14, 3, 1, 1) self.slider_block.addWidget(self.lineedit_amb_diff_spec_rm, 14, 4, 1, 1) self.slider_block.addWidget(self.button_set_amb_diff_spec_rm, 14, 5, 1, 1) self.hl_image_specs = Qt.QHBoxLayout() self.hl_image_specs.addWidget(self.label_image_data_size) self.hl_image_specs.addWidget(self.label_display_image_data_size, stretch=3) self.hl_image_specs.addWidget(self.label_placeholder) self.hl_image_specs.addWidget(self.button_set_interpolation_dims) self.hl_image_specs.addWidget(self.lineedit_interpolation_dim_x, stretch=1) self.hl_image_specs.addWidget(self.label_x_1, stretch=0.5) self.hl_image_specs.addWidget(self.lineedit_interpolation_dim_y, stretch=1) self.hl_image_specs.addWidget(self.label_x_2, stretch=0.5) self.hl_image_specs.addWidget(self.lineedit_interpolation_dim_z, stretch=1) # Definition of the vertical and horizontal main axis self.vl_main = Qt.QVBoxLayout() self.hl_main = Qt.QHBoxLayout() self.frame.setLayout(self.hl_main) # Align all widgets or horizontal layouts along the vertical main axis self.vl_main.addLayout(self.hl_load_buttons) self.vl_main.addLayout(self.hl_checkboxes) self.vl_main.addWidget(self.diag.canvas) self.vl_main.addWidget(self.label_text_above_image_data) self.vl_main.addLayout(self.hl_image_specs) self.vl_main.addWidget(self.label_placeholder) self.vl_main.addWidget(self.label_text_above_playback_settings) self.vl_main.addLayout(self.hl_playback_settings) self.vl_main.addLayout(self.hl_playback_speed) self.vl_main.addWidget(self.label_placeholder) self.vl_main.addLayout(self.slider_block) self.vl_main.addWidget(self.label_placeholder) self.vl_main.addWidget(self.label_camera_operations) self.vl_main.addLayout(self.grid_camera_operations) # Alignment along horizontal main axis self.hl_main.addLayout(self.vl_main, stretch=1) self.hl_main.addWidget(self.vtkWidget, stretch=2)
def __init__(self, bottom, parent=None): super(IntLineEdit, self).__init__(parent) validator = Qt.QIntValidator() validator.setBottom(bottom) self.setValidator(validator) self.setValue(bottom)
def initWidgets(self): self.gpredict_ip_le = Qt.QLineEdit() self.gpredict_ip_le.setText(self.pred_ip) self.gpredict_ip_le.setInputMask("000.000.000.000;") self.gpredict_ip_le.setEchoMode(Qt.QLineEdit.Normal) self.gpredict_ip_le.setStyleSheet( "QLineEdit {background-color:rgb(255,255,255); color:rgb(0,0,0);}") self.gpredict_ip_le.setMaxLength(15) self.gpredict_ip_le.setFixedHeight(20) self.gpredict_ip_le.setFixedWidth(125) self.gpredict_port_le = Qt.QLineEdit() self.gpredict_port_le.setText(str(self.pred_port)) self.port_validator = Qt.QIntValidator() self.port_validator.setRange(0, 65535) self.gpredict_port_le.setValidator(self.port_validator) self.gpredict_port_le.setEchoMode(Qt.QLineEdit.Normal) self.gpredict_port_le.setStyleSheet( "QLineEdit {background-color:rgb(255,255,255); color:rgb(0,0,0);}") self.gpredict_port_le.setMaxLength(5) self.gpredict_port_le.setFixedWidth(50) self.gpredict_port_le.setFixedHeight(20) label = Qt.QLabel('Status:') label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) label.setStyleSheet("QLabel {color:rgb(255,255,255);}") label.setFixedHeight(10) self.pred_status_lbl = Qt.QLabel('Disconnected') self.pred_status_lbl.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.pred_status_lbl.setStyleSheet( "QLabel {font-weight:bold; color:rgb(255,0,0);}") self.pred_status_lbl.setFixedWidth(125) self.pred_status_lbl.setFixedHeight(10) self.predict_button = Qt.QPushButton("Start Predict Server") self.predict_button.setFixedHeight(20) lbl1 = Qt.QLabel('Az:') lbl1.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) lbl1.setStyleSheet("QLabel {color:rgb(255,255,255)}") lbl1.setFixedWidth(25) lbl1.setFixedHeight(10) lbl2 = Qt.QLabel('El:') lbl2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) lbl2.setStyleSheet("QLabel {color:rgb(255,255,255)}") lbl2.setFixedWidth(25) lbl2.setFixedHeight(10) self.pred_az_lbl = Qt.QLabel('XXX.X') self.pred_az_lbl.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.pred_az_lbl.setStyleSheet("QLabel {color:rgb(255,255,255)}") self.pred_az_lbl.setFixedWidth(50) self.pred_az_lbl.setFixedHeight(10) self.pred_el_lbl = Qt.QLabel('XXX.X') self.pred_el_lbl.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.pred_el_lbl.setStyleSheet("QLabel {color:rgb(255,255,255)}") self.pred_el_lbl.setFixedWidth(50) self.pred_el_lbl.setFixedHeight(10) self.auto_track_cb = Qt.QCheckBox("Auto Track") self.auto_track_cb.setStyleSheet( "QCheckBox { background-color:rgb(0,0,0); color:rgb(255,255,255); }" ) self.auto_track_cb.setFixedHeight(20) hbox1 = Qt.QHBoxLayout() hbox1.addWidget(self.gpredict_ip_le) hbox1.addWidget(self.gpredict_port_le) hbox2 = Qt.QHBoxLayout() hbox2.addWidget(label) hbox2.addWidget(self.pred_status_lbl) hbox3 = Qt.QHBoxLayout() hbox3.addWidget(lbl1) hbox3.addWidget(self.pred_az_lbl) hbox4 = Qt.QHBoxLayout() hbox4.addWidget(lbl2) hbox4.addWidget(self.pred_el_lbl) vbox1 = Qt.QVBoxLayout() vbox1.addLayout(hbox3) vbox1.addLayout(hbox4) hbox5 = Qt.QHBoxLayout() hbox5.addWidget(self.auto_track_cb) hbox5.addLayout(vbox1) vbox = Qt.QVBoxLayout() vbox.addLayout(hbox1) vbox.addWidget(self.predict_button) vbox.addLayout(hbox2) vbox.addLayout(hbox5) self.setLayout(vbox)
def __init__(self, node, astergui, parent=None): # pragma pylint: disable=too-many-locals """ Create editor panel. Arguments: node (Stage, Unit): Object to manage. astergui (AsterGui): *AsterGui* instance. parent (Optional[QWidget]): Parent widget. Defaults to *None*. """ #---------------------------------------------------------------------- super(UnitPanel, self).__init__(parent=parent, name="", astergui=astergui) #---------------------------------------------------------------------- self.node = node self.prev_unit = None self.unit = None #---------------------------------------------------------------------- # set title title = translate("UnitPanel", "Edit data file") \ if self.mode == UnitPanel.EditMode \ else translate("UnitPanel", "Add data file") self._controllername = title self.setWindowTitle(title) # set icon pixmap = load_pixmap("as_pic_edit_file.png") \ if self.mode == UnitPanel.EditMode \ else load_pixmap("as_pic_new_file.png") self.setPixmap(pixmap) #---------------------------------------------------------------------- # top-level layout v_layout = Q.QVBoxLayout(self) v_layout.setContentsMargins(0, 0, 0, 0) #---------------------------------------------------------------------- # top level widget to easily manage read-only mode self.frame = Q.QWidget(self) v_layout.addWidget(self.frame) #---------------------------------------------------------------------- # main layout glayout = Q.QGridLayout(self.frame) glayout.setContentsMargins(0, 0, 0, 0) #---------------------------------------------------------------------- # 'Mode' controls label = Q.QLabel(translate("DataFiles", "Mode"), self.frame) glayout.addWidget(label, 0, 0) self.attr_combo = Q.QComboBox(self.frame) self.attr_combo.setObjectName("Mode") attr_list = [FileAttr.In, FileAttr.Out, FileAttr.InOut] for attr in attr_list: self.attr_combo.addItem(FileAttr.value2str(attr), attr) self.attr_combo.setCurrentIndex(-1) glayout.addWidget(self.attr_combo, 0, 1) #---------------------------------------------------------------------- label = Q.QLabel(translate("DataFiles", "Filename"), self.frame) glayout.addWidget(label, 1, 0) self.file_combo = Q.QComboBox(self.frame) self.file_combo.setObjectName("Filename") glayout.addWidget(self.file_combo, 1, 1, 1, 2) self.file_btn = Q.QToolButton(self.frame) self.file_btn.setText("...") self.file_btn.setObjectName("Filename") glayout.addWidget(self.file_btn, 1, 3) #---------------------------------------------------------------------- # 'Unit' controls label = Q.QLabel(translate("DataFiles", "Unit"), self.frame) glayout.addWidget(label, 2, 0) self.unit_edit = Q.QLineEdit(self.frame) self.unit_edit.setObjectName("Unit") self.unit_edit.setValidator(Q.QIntValidator(2, 99, self.unit_edit)) glayout.addWidget(self.unit_edit, 2, 1) #---------------------------------------------------------------------- # 'Exists' controls label = Q.QLabel(translate("DataFiles", "Exists"), self.frame) glayout.addWidget(label, 3, 0) self.exists_check = Q.QCheckBox(self.frame) self.exists_check.setObjectName("Exists") self.exists_check.setEnabled(False) glayout.addWidget(self.exists_check, 3, 1) #---------------------------------------------------------------------- # 'Embedded' controls label = Q.QLabel(translate("DataFiles", "Embedded"), self.frame) glayout.addWidget(label, 4, 0) self.embedded_check = Q.QCheckBox(self.frame) self.embedded_check.setObjectName("Embedded") glayout.addWidget(self.embedded_check, 4, 1) #---------------------------------------------------------------------- # tune layout glayout.setColumnStretch(1, 2) glayout.setColumnStretch(2, 2) glayout.setRowStretch(glayout.rowCount(), 10) #---------------------------------------------------------------------- # initialize unit model file_model = UnitModel(self.stage) self.file_combo.setModel(file_model) self.file_combo.setCurrentIndex(-1) #---------------------------------------------------------------------- # initialize controls from data model object if self.mode == UnitPanel.EditMode: self.setEditData(node) #---------------------------------------------------------------------- # connections connect(self.file_combo.currentIndexChanged, self.updateControls) connect(self.file_combo.currentIndexChanged, self.updateButtonStatus) connect(self.file_btn.clicked, self.browseFile) connect(self.unit_edit.textChanged, self.updateButtonStatus) connect(self.attr_combo.currentIndexChanged, self.updateButtonStatus) connect(self.embedded_check.toggled, self.embeddedChanged) connect(file_model.rowsAboutToBeInserted, self.beforeUpdate) connect(file_model.rowsInserted, self.afterUpdate) connect(file_model.rowsAboutToBeRemoved, self.beforeUpdate) connect(file_model.rowsRemoved, self.afterUpdate) #---------------------------------------------------------------------- # update status self.updateControls()
def __init__(self, layer_stack, parent=None): super().__init__(parent) self.layer_stack = layer_stack self.pages_view = PagesView() pages = PageList() self.pages_model = PagesModel(property_names=self.DISPLAY_PROPERTIES, signaling_list=pages, parent=self.pages_view) pages.replaced.connect(self._on_pages_replaced) self.pages_model.handle_dropped_files = self._handle_dropped_files self.pages_model.rowsInserted.connect(self._on_model_change) self.pages_model.rowsRemoved.connect(self._on_model_change) self.pages_model.rowsInserted.connect(self._on_rows_inserted_indirect, Qt.Qt.QueuedConnection) self.pages_view.setModel(self.pages_model) self.pages_view.selectionModel().currentRowChanged.connect(self.apply) self.pages_view.selectionModel().selectionChanged.connect(self._on_page_selection_changed) self._attached_page = None Qt.QShortcut(Qt.Qt.Key_Up, self, self.focus_prev_page, context=Qt.Qt.ApplicationShortcut) Qt.QShortcut(Qt.Qt.Key_Down, self, self.focus_next_page, context=Qt.Qt.ApplicationShortcut) layout = Qt.QVBoxLayout() layout.setSpacing(0) self.setLayout(layout) layout.addWidget(self.pages_view) mergebox = Qt.QHBoxLayout() mergebox.setSpacing(11) self.merge_button = Qt.QPushButton('Merge pages') self.merge_button.clicked.connect(self.merge_selected) mergebox.addWidget(self.merge_button) self.delete_button = Qt.QPushButton('Delete pages') self.delete_button.clicked.connect(self.delete_selected) Qt.QShortcut(Qt.Qt.Key_Delete, self, self.delete_button.click, context=Qt.Qt.WidgetWithChildrenShortcut) Qt.QShortcut(Qt.Qt.Key_Backspace, self, self.delete_button.click, context=Qt.Qt.WidgetWithChildrenShortcut) mergebox.addWidget(self.delete_button) layout.addLayout(mergebox) playbox = Qt.QHBoxLayout() playbox.setSpacing(11) self.play_button = Qt.QPushButton('\N{BLACK RIGHT-POINTING POINTER}') self.play_button.setCheckable(True) self.play_button.setEnabled(False) self.play_button.toggled.connect(self._on_play_button_toggled) playbox.addSpacerItem(Qt.QSpacerItem(0, 0, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum)) playbox.addWidget(self.play_button) self.fps_editor = Qt.QLineEdit() self.fps_editor.setValidator(Qt.QIntValidator(1, 99, parent=self)) self.fps_editor.editingFinished.connect(self._on_fps_editing_finished) self.fps_editor.setFixedWidth(30) self.fps_editor.setAlignment(Qt.Qt.AlignCenter) playbox.addWidget(self.fps_editor) playbox.addWidget(Qt.QLabel('FPS')) playbox.addSpacerItem(Qt.QSpacerItem(0, 0, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum)) layout.addLayout(playbox) self.playback_timer = Qt.QTimer() self.playback_timer.timeout.connect(self.advance_frame) self.playback_fps = 30 self._on_page_selection_changed() self.apply()
def __init__(self, parent=None): self.clipboard = QtWidgets.QApplication.clipboard() QtWidgets.QMainWindow.__init__(self, parent) m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(app_logo)) self.setWindowIcon(Qt.QIcon(m_ico)) self.setWindowTitle(WINDOWS_TITLE) self.resize(440, 100) self.window = Qt.QWidget() self.layout_main = Qt.QGridLayout() self.layout_main.setContentsMargins(8, 4, 4, 8) self.layout_main.setSpacing(3) self.window.setLayout(self.layout_main) lbl1 = QtWidgets.QLabel() m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(pass_easy)) lbl1.setPixmap(QtGui.QPixmap(m_ico)) self.textPasswd1 = Qt.QLineEdit() self.textPasswd1.setStyleSheet(PASSWD_STYLE) self.textPasswd1Len = Qt.QLineEdit() self.textPasswd1Len.setStyleSheet(PASSWDLEN_STYLE) self.textPasswd1Len.setText('8') self.textPasswd1Len.setFixedWidth(29) self.textPasswd1Len.setValidator( Qt.QIntValidator(MIN_EASY_SIZE, MAX_EASY_SIZE)) self.textPasswd1Len.textChanged.connect(self.get_passwd_simple) self.layout_main.addWidget(lbl1, 0, 0) self.layout_main.addWidget(self.textPasswd1, 0, 1) self.layout_main.addWidget(self.textPasswd1Len, 0, 2) new_menu1 = QtWidgets.QAction(QtGui.QIcon(m_ico), 'Refresh simple password', self) new_menu1.setShortcut(SIMPLE_SHORTCUT) new_menu1.triggered.connect(self.get_passwd_simple) m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(refresh_icon)) new_act1 = QtWidgets.QPushButton() new_act1.setIcon(QtGui.QIcon(m_ico)) new_act1.setIconSize(m_ico.rect().size()) self.layout_main.addWidget(new_act1, 0, 3) new_act1.clicked.connect(self.get_passwd_simple) lbl2 = QtWidgets.QLabel() m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(pass_medium)) lbl2.setPixmap(QtGui.QPixmap(m_ico)) self.textPasswd2 = Qt.QLineEdit() self.textPasswd2.setStyleSheet(PASSWD_STYLE) self.textPasswd2Len = Qt.QLineEdit() self.textPasswd2Len.setStyleSheet(PASSWDLEN_STYLE) self.textPasswd2Len.setText('12') self.textPasswd2Len.setFixedWidth(29) self.textPasswd2Len.setValidator( Qt.QIntValidator(MIN_MEDIUM_SIZE, MAX_MEDIUM_SIZE)) self.textPasswd2Len.textChanged.connect(self.get_passwd_medium) self.get_passwd_medium() self.layout_main.addWidget(lbl2, 1, 0) self.layout_main.addWidget(self.textPasswd2, 1, 1) self.layout_main.addWidget(self.textPasswd2Len, 1, 2) new_menu2 = QtWidgets.QAction(QtGui.QIcon(m_ico), 'Refresh medium password', self) new_menu2.setShortcut(MEDIUM_SHORTCUT) new_menu2.triggered.connect(self.get_passwd_medium) m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(refresh_icon)) new_act2 = QtWidgets.QPushButton() new_act2.setIcon(QtGui.QIcon(m_ico)) new_act2.setIconSize(m_ico.rect().size()) self.layout_main.addWidget(new_act2, 1, 3) new_act2.clicked.connect(self.get_passwd_medium) lbl3 = QtWidgets.QLabel() m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(pass_strong)) lbl3.setPixmap(QtGui.QPixmap(m_ico)) self.textPasswd3 = Qt.QLineEdit() self.textPasswd3.setStyleSheet(PASSWD_STYLE) self.textPasswd3Len = Qt.QLineEdit() self.textPasswd3Len.setStyleSheet(PASSWDLEN_STYLE) self.textPasswd3Len.setText('24') self.textPasswd3Len.setFixedWidth(29) self.textPasswd3Len.setValidator( Qt.QIntValidator(MIN_STRONG_SIZE, MAX_STRONG_SIZE)) self.textPasswd3Len.textChanged.connect(self.get_passwd_strong) self.get_passwd_strong() self.layout_main.addWidget(lbl3, 2, 0) self.layout_main.addWidget(self.textPasswd3, 2, 1) self.layout_main.addWidget(self.textPasswd3Len, 2, 2) new_menu3 = QtWidgets.QAction(QtGui.QIcon(m_ico), 'Refresh strong password', self) new_menu3.setShortcut(STRONG_SHORTCUT) new_menu3.triggered.connect(self.get_passwd_strong) m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(refresh_icon)) new_act3 = QtWidgets.QPushButton() new_act3.setIcon(QtGui.QIcon(m_ico)) new_act3.setIconSize(m_ico.rect().size()) self.layout_main.addWidget(new_act3, 2, 3) new_act3.clicked.connect(self.get_passwd_strong) lbl4 = QtWidgets.QLabel() m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(refresh_icon)) lbl4.setPixmap(QtGui.QPixmap(m_ico)) self.textPasswd4 = Qt.QLineEdit() self.textPasswd4.setStyleSheet(PASSWD_STYLE) self.textPasswd4.setText('example_text_to_turn') self.layout_main.addWidget(lbl4, 3, 0) self.layout_main.addWidget(self.textPasswd4, 3, 1) new_menu4 = QtWidgets.QAction(QtGui.QIcon(m_ico), 'Update `turn` password', self) new_menu4.setShortcut(TURN_SHORTCUT) new_menu4.triggered.connect(self.get_passwd_turn) m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(refresh_icon)) new_act4 = QtWidgets.QPushButton() new_act4.setIcon(QtGui.QIcon(m_ico)) new_act4.setIconSize(m_ico.rect().size()) self.layout_main.addWidget(new_act4, 3, 3) new_act4.clicked.connect(self.get_passwd_turn) m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(exit_icon)) quit_act = QtWidgets.QPushButton() quit_act.setIcon(QtGui.QIcon(m_ico)) quit_act.setIconSize(m_ico.rect().size()) quit_act.setStyleSheet(EXIT_BUTTON_STYLE) self.layout_main.addWidget(quit_act, 4, 0, 1, 4) quit_act.clicked.connect(self.close) exit_menu = QtWidgets.QAction(QtGui.QIcon(m_ico), 'Quit', self) exit_menu.setShortcut(EXIT_SHORTCUT) exit_menu.triggered.connect(self.close) m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(info_icon)) help_menu = QtWidgets.QAction(QtGui.QIcon(m_ico), 'Help', self) help_menu.setShortcut(HELP_SHORTCUT) help_menu.triggered.connect(self.help_info) m_ico = QtGui.QPixmap() m_ico.loadFromData(base64.b64decode(about_icon)) about_menu = QtWidgets.QAction(QtGui.QIcon(m_ico), 'About me', self) about_menu.setShortcut(ABOUT_SHORTCUT) about_menu.triggered.connect(self.about_info) self.setCentralWidget(self.window) self.get_passwd_simple() menubar = self.menuBar() menu_f = menubar.addMenu('&Menu') menu_f.addAction(new_menu1) menu_f.addAction(new_menu2) menu_f.addAction(new_menu3) menu_f.addAction(new_menu4) menu_f.addSeparator() menu_f.addAction(exit_menu) menu_h = menubar.addMenu('&Help') menu_h.addAction(help_menu) menu_h.addAction(about_menu)
def setupUi(self, Login): Login.setObjectName("Login") Login.resize(800, 600) Login.setFixedSize(800, 600) Login.setWindowFlags(Qt.Qt.FramelessWindowHint) Login.setWindowTitle('淡江大學 實習上機系統') img = base64.b64decode(tku) Login.setWindowIcon( QtGui.QIcon(self.svg2pixmap(img, Qt.QSize(512, 512)))) self.centralwidget = QtWidgets.QWidget(Login) self.centralwidget.setObjectName("centralwidget") # -- left self.left = QtWidgets.QFrame(self.centralwidget) self.left.setGeometry(QtCore.QRect(0, 0, 300, 800)) self.left.setStyleSheet("QFrame{background-color: rgb(207, 49, 49)}") self.left.setObjectName("left") self.logo = QtWidgets.QLabel(self.left) self.logo.setFixedSize(110, 110) img = base64.b64decode(logopng) img = BytesIO(img) img = Image.open(img) img = ImageQt.ImageQt(img) self.logo.setPixmap(QtGui.QPixmap.fromImage(img)) self.logo.setScaledContents(True) self.logo.setGeometry( QtCore.QRect(int(150 - self.logo.width() / 2), 120, 110, 110)) self.school = QtWidgets.QLabel(self.left) self.school.setText('<font color=#FFFFFF>淡江大學</font>') self.school.setFont(QtGui.QFont('微軟正黑體', 15)) self.school.adjustSize() self.school.setGeometry( QtCore.QRect(int(150 - self.school.width() / 2), 250, int(self.school.width()), int(self.school.height()))) self.slogan = QtWidgets.QLabel(self.left) self.slogan.setText('<font color=#ffffff>國際化|資訊化|未來化</font>') self.slogan.setFont(QtGui.QFont('微軟正黑體', 10)) self.slogan.adjustSize() self.slogan.setGeometry( QtCore.QRect(int(150 - self.slogan.width() / 2), 285, int(self.slogan.width()), int(self.slogan.height()))) self.title = QtWidgets.QLabel(self.left) self.title.setText('<font color=#ffffff>實習上機系統</font>') self.title.setFont(QtGui.QFont('微軟正黑體', 18, QtGui.QFont.Bold)) self.title.adjustSize() self.title.setGeometry( QtCore.QRect(int(150 - self.title.width() / 2), 400, int(self.title.width()), int(self.title.height()))) # -- # -- right self.right = QtWidgets.QFrame(self.centralwidget) self.right.setGeometry(QtCore.QRect(300, 0, 500, 800)) self.right.setStyleSheet('QFrame{background-color: #ffffff}') self.right.setObjectName("right") Login.setCentralWidget(self.centralwidget) self.logintitle = QtWidgets.QLabel(self.right) self.logintitle.setText('<font color=#5A5858>登入LOGIN</font>') self.logintitle.setFont(QtGui.QFont('微軟正黑體', 20)) self.logintitle.adjustSize() self.logintitle.setGeometry( Qt.QRect(40, 150, int(self.logintitle.width()), int(self.logintitle.height()))) self.usernameicon = QtSvg.QSvgWidget(self.right) img = base64.b64decode(user) self.usernameicon.load(img) self.usernameicon.setGeometry(Qt.QRect(90, 250, 30, 30)) self.username = QtWidgets.QLineEdit(self.right) self.username.setGeometry(Qt.QRect(130, 250, 260, 30)) self.username.setStyleSheet( 'QLineEdit{border-style:none;padding:6px;border-radius:5px;border:2px solid #5A5858;}QLineEdit:focus{border-style:none;padding:6px;border-radius:5px;border:2px solid #CF3131;}' ) self.username.setFont(QtGui.QFont('微軟正黑體', 12)) self.username.setValidator(Qt.QIntValidator()) self.passwordicon = QtSvg.QSvgWidget(self.right) img = base64.b64decode(lock) self.passwordicon.load(img) self.passwordicon.setGeometry(Qt.QRect(90, 300, 30, 30)) reg = QtCore.QRegExp('[A-Za-z0-9!@#*.]+$') passwordVaildator = Qt.QRegExpValidator() passwordVaildator.setRegExp(reg) self.password = QtWidgets.QLineEdit(self.right) self.password.setGeometry(Qt.QRect(130, 300, 260, 30)) self.password.setStyleSheet( 'QLineEdit{border-style:none;padding:6px;border-radius:5px;border:2px solid #5A5858;}QLineEdit:focus{border-style:none;padding:6px;border-radius:5px;border:2px solid #CF3131;}' ) self.password.setFont(QtGui.QFont('微軟正黑體', 12)) self.password.setEchoMode(QtWidgets.QLineEdit.Password) self.password.setValidator(passwordVaildator) self.login = QtWidgets.QPushButton(self.right) self.login.setGeometry( Qt.QRect(int(250 - self.login.width() / 2), 380, 80, 35)) self.login.setText('登入') self.login.setFont(QtGui.QFont('微軟正黑體', 12)) self.login.setStyleSheet( 'QPushButton{border-style:none; padding:6px; border-radius:5px; border:2px solid #CF3131; color: white; background-color: #CF3131} QPushButton:hover{border-style:none; padding:6px; border:2px solid #CF3131; background-color:#CF3131; color:white; font-weight: 700;} QPushButton:pressed{border-style:none; padding:6px; border:2px solid #A20C0C; background-color:#A20C0C; color:white;}' ) self.status = QtWidgets.QLabel(self.right) self.status.setFont(QtGui.QFont('微軟正黑體', 10)) self.status.setStyleSheet('QLabel{color: red;}') self.status.adjustSize() self.status.setGeometry( Qt.QRect(int(250 - self.status.width() / 2), 350, int(self.status.width()), int(self.status.height()))) self.close = QtWidgets.QPushButton(self.right) img = base64.b64decode(close) self.close.setIcon(QtGui.QIcon(self.svg2pixmap(img, Qt.QSize(25, 25)))) self.close.setIconSize(QtCore.QSize(25, 25)) self.close.setGeometry(Qt.QRect(430, 35, 25, 25)) self.close.setStyleSheet( 'QPushButton{background-color: transparent; border-style:none;} QPushButton:hover{background-color: #eeeeee; border-style:none; border-radius:5px;} QPushButton:pressed{background-color: #999999; border-style:none; border-radius:5px;}' ) self.contact = QtWidgets.QLabel(self.right) self.contact.setText('淡江大學資訊處 教學支援組 (02)2621-5656 #2628') self.contact.setFont(QtGui.QFont('微軟正黑體', 8)) self.contact.setStyleSheet('QLabel{color: #5A5858;}') self.contact.adjustSize() self.contact.setGeometry( Qt.QRect(int(250 - self.contact.width() / 2), 550, int(self.contact.width()), int(self.contact.height()))) self.copyright = QtWidgets.QLabel(self.right) self.copyright.setText( 'Copyright © 2020 CHANG CHIH HSIANG. All rights reserved') self.copyright.setFont(QtGui.QFont('微軟正黑體', 8)) self.copyright.setStyleSheet('QLabel{color: #5A5858;}') self.copyright.adjustSize() self.copyright.setGeometry( Qt.QRect(int(250 - self.copyright.width() / 2), 565, int(self.copyright.width()), int(self.copyright.height()))) # -- # -- loading loadingOpacity = QtWidgets.QGraphicsOpacityEffect() loadingOpacity.setOpacity(0.5) self.loading = QtWidgets.QFrame(self.centralwidget) self.loading.setGeometry(QtCore.QRect(0, 0, 800, 600)) self.loading.setStyleSheet('QFrame{background-color: black;}') self.loading.setAutoFillBackground(True) self.loading.setGraphicsEffect(loadingOpacity) self.loading.setVisible(False) self.loadingLabel = QtWidgets.QLabel(self.loading) self.loadingLabel.setText('登入中,請稍後') self.loadingLabel.setFont(QtGui.QFont('微軟正黑體', 15, QtGui.QFont.Bold)) self.loadingLabel.setStyleSheet('QLabel{color: white;}') self.loadingLabel.adjustSize() self.loadingLabel.setGeometry( QtCore.QRect(int(400 - self.loadingLabel.width() / 2), int(300 - self.loadingLabel.height() / 2), self.loadingLabel.width(), self.loadingLabel.height())) # -- self.retranslateUi(Login) QtCore.QMetaObject.connectSlotsByName(Login)