def initUI(self): self.setWindowTitle("查看回收站文件夹内容") self.form = QVBoxLayout() for item in iter(self.files): ico = QPushButton(set_file_icon(item.name), item.name) ico.setStyleSheet( "QPushButton {border:none; background:transparent; color:black;}" ) ico.adjustSize() it = QLabel(f"<font color='#CCCCCC'>({item.size})</font>") hbox = QHBoxLayout() hbox.addWidget(ico) hbox.addStretch(1) hbox.addWidget(it) self.form.addLayout(hbox) self.form.setSpacing(10) self.buttonBox = QDialogButtonBox() self.buttonBox.setOrientation(Qt.Orientation.Horizontal) self.buttonBox.setStandardButtons( QDialogButtonBox.StandardButton.Close) self.buttonBox.button( QDialogButtonBox.StandardButton.Close).setText("关闭") self.buttonBox.setStyleSheet(btn_style) self.buttonBox.rejected.connect(self.reject) vbox = QVBoxLayout() vbox.addLayout(self.form) vbox.addStretch(1) vbox.addWidget(self.buttonBox) self.setLayout(vbox)
def initUI(self): OVER_CAPACITY = 750 sld = QSlider(Qt.Orientations.Horizontal, self) sld.setFocusPolicy(Qt.FocusPolicy.NoFocus) sld.setRange(1, OVER_CAPACITY) sld.setValue(75) sld.setGeometry(30, 40, 150, 30) self.c = Communicate() self.wid = BurningWidget() self.c.updateBW[int].connect(self.wid.setValue) sld.valueChanged[int].connect(self.changeValue) hbox = QHBoxLayout() hbox.addWidget(self.wid) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addLayout(hbox) self.setLayout(vbox) self.setGeometry(300, 300, 390, 210) self.setWindowTitle('Burning widget') self.show()
def __init__(self, parent, directory, is_checked): """Simple modal Preferences dialog""" super().__init__(parent) self.setWindowTitle("Preferences") self.setModal(True) image_dir_label = QLabel( f"<b>Images Location:</b> {directory.absolutePath()}") self.delete_images_checkbox = QCheckBox("Delete Original Images") self.delete_images_checkbox.setToolTip( """<p>If checked, images that are copied to the <b>Images Location</b> are also deleted from their original location.</p>""" ) self.delete_images_checkbox.setChecked(is_checked) handling_v_box = QVBoxLayout() handling_v_box.addWidget(self.delete_images_checkbox) handling_group_box = QGroupBox("Image Handling:") handling_group_box.setLayout(handling_v_box) self.button_box = QDialogButtonBox( QDialogButtonBox.StandardButton.Save | QDialogButtonBox.StandardButton.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) # Add a layout to the dialog box dialog_v_box = QVBoxLayout() dialog_v_box.addWidget(image_dir_label) dialog_v_box.addWidget(handling_group_box) dialog_v_box.addStretch(1) dialog_v_box.addWidget(self.button_box) self.setLayout(dialog_v_box)
class MainWidget(QWidget): def __init__(self): super(MainWidget, self).__init__() self.resize(500, 600) self.setWindowTitle("喜马拉雅下载 by[Zero] " + __VERSION__) self.mainlayout = QVBoxLayout() self.setLayout(self.mainlayout) self.groupbox = QGroupBox("选择类型") self.groupbox.setFixedHeight(50) hlayout = QHBoxLayout(self.groupbox) self.signal_m4a = QRadioButton("单个下载") self.mut_m4a = QRadioButton("专辑下载") self.vip_signal_m4a = QRadioButton("VIP单个下载") self.vip_m4a = QRadioButton("VIP专辑下载") hlayout.addWidget(self.signal_m4a) hlayout.addWidget(self.mut_m4a) hlayout.addWidget(self.vip_signal_m4a) hlayout.addWidget(self.vip_m4a) self.mainlayout.addWidget(self.groupbox) frame01 = QFrame(self) child_layout = QVBoxLayout() print(self.width()) label01 = QLabel("链 接", self) label02 = QLabel("下载目录", self) self.url_lineedit = QLineEdit(self) self.dir_lineedit = QLineEdit(self) hlayout01 = QHBoxLayout() hlayout01.addWidget(label01, 1) hlayout01.addWidget(self.url_lineedit, 9) hlayout02 = QHBoxLayout() hlayout02.addWidget(label02, 1) hlayout02.addWidget(self.dir_lineedit, 9) child_layout.addLayout(hlayout01) child_layout.addLayout(hlayout02) child_layout.setContentsMargins( 5, 0, 5, 0) #(int left, int top, int right, int bottom) frame01.setLayout(child_layout) self.download_progressbar = QProgressBar() self.download_progressbar.setAlignment( QtCore.Qt.Alignment.AlignCenter) #文字居中 self.download_progressbar.setValue(88) self.download_btn = QPushButton("开始下载") self.show_plaintextedit = QPlainTextEdit() self.show_plaintextedit.setMinimumHeight(400) self.mainlayout.addWidget(frame01) self.mainlayout.addWidget(self.download_progressbar) self.mainlayout.addWidget(self.download_btn) self.mainlayout.addWidget(self.show_plaintextedit) self.mainlayout.addStretch() ### 设置stylesheet self.download_btn.setStyleSheet( 'QPushButton:pressed{ text-align: center;background-color:red;}')
def __init__(self): app = QApplication(sys.argv) super().__init__() self.setWindowTitle('Generic Configuration Tool') self.setGeometry(100, 100, 640, 480) self.isEdited = False self.saveAndClose = SaveAndCloseActions(self) centralWidget = QWidget() vbox = QVBoxLayout() centralWidget.setLayout(vbox) vbox.addWidget(TabContainer(self)) vbox.addStretch(1) vbox.addWidget(self.saveAndClose) self.setCentralWidget(centralWidget) self.show() sys.exit(app.exec())
def __init__(self): super(MainUi, self).__init__() self.setFixedSize(600,500) self.setWindowTitle("妹子图爬虫工具 version: 1.0.0 ") self.download_progressbar = QProgressBar() self.download_progressbar.setAlignment(QtCore.Qt.Alignment.AlignCenter)#文字居中 self.download_progressbar.setStyleSheet(".QProgressBar::chunk { background-color: red;}")#背景 self.download_progressbar.setValue(100) label01 = QLabel("下载URL:") label02 = QLabel("下载目录:") self.url_input = QLineEdit() self.url_input.setText("https://www.mzitu.com/221746") self.url_input.setContentsMargins(0,0,0,0) self.download_dir = QLineEdit() self.download_dir.setContentsMargins(0,0,0,0) self.start_btn = QPushButton("开始爬虫") self.start_btn.setFixedHeight(50) self.start_btn.setContentsMargins(0,0,0,0) inputlayout = QGridLayout() inputlayout.addWidget(label01, 0, 0) #第0行 0列 inputlayout.addWidget(label02, 1, 0) inputlayout.addWidget(self.url_input, 0, 1) inputlayout.addWidget(self.download_dir, 1, 1) inputlayout.addWidget(self.start_btn, 0, 2, 2,1,QtCore.Qt.Alignment.AlignRight) #起始行,起始列, 占行数,占列数 inputlayout.setColumnStretch(0, 1) #设置每一列比例 inputlayout.setColumnStretch(1, 10) inputlayout.setColumnStretch(2, 1) vlayout = QVBoxLayout() vlayout.addLayout(inputlayout) vlayout.addWidget(self.download_progressbar) self.frame = QFrame() self.frame.setFixedHeight(400) vlayout.addWidget(self.frame) vlayout.addStretch() inputlayout.setContentsMargins(0,0,0,0) vlayout01 = QVBoxLayout() self.frame.setLayout(vlayout01) self.qtablewidget = QTableWidget(1,3) self.qtablewidget.setHorizontalHeaderLabels(['目录','下载图片总数目', '删除']) vlayout01.addWidget(self.qtablewidget) self.qtablewidget.setColumnWidth(0, 358) # 将第0列的单元格,设置成300宽度 self.qtablewidget.setColumnWidth(1, 100 ) # 将第0列的单元格,设置成50宽度 self.qtablewidget.verticalHeader().setVisible(False) #隐藏水平表头 #self.qtablewidget.setDisabled(True) #设置不可编辑 self.setLayout(vlayout) self.current_index = 0
def __init__(self, parent, selected_image): """Modeless dialog that displays file information for images""" super().__init__(parent) metadata = self.collectImageMetaData(selected_image) self.setWindowTitle(f"{metadata['file_name']} Info") # Create widgets for displaying information image_label = QLabel(f"<b>{metadata['base_name']}</b>") date_created = QLabel( f"Created: {metadata['date_created'].toString('MMMM d, yyyy h:mm:ss ap')}" ) image_type = QLabel(f"Type: {metadata['extension']}") image_size = QLabel(f"Size: {metadata['size']:,} bytes") image_location = QLabel(f"Location: {metadata['file_path']}") date_modified = QLabel( f"""Modified: {metadata['last_modified'].toString('MMMM d, yyyy h:mm:ss ap')}""" ) # Organize widgets that display metadata using containers/layouts general_v_box = QVBoxLayout() general_v_box.addWidget(image_type) general_v_box.addWidget(image_size) general_v_box.addWidget(image_location) general_group_box = QGroupBox("General:") general_group_box.setLayout(general_v_box) extra_v_box = QVBoxLayout() extra_v_box.addWidget(date_modified) extra_group_box = QGroupBox("Extra Info:") extra_group_box.setLayout(extra_v_box) self.button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok) self.button_box.accepted.connect(self.accept) # Add a layout to the dialog box dialog_v_box = QVBoxLayout() dialog_v_box.addWidget(image_label) dialog_v_box.addWidget(date_created) dialog_v_box.addWidget(general_group_box) dialog_v_box.addWidget(extra_group_box) dialog_v_box.addStretch(1) dialog_v_box.addWidget(self.button_box) self.setLayout(dialog_v_box)
def initUI(self): self.setWindowTitle("合并文件") self.setWindowIcon(QIcon(SRC_DIR + "upload.ico")) self.logo = QLabel() self.logo.setPixmap(QPixmap(SRC_DIR + "logo3.gif")) self.logo.setStyleSheet("background-color:rgb(0,153,255);") self.logo.setAlignment(Qt.AlignmentFlag.AlignCenter) # lable self.choose_lb = QLabel("选择文件夹") # folder self.choose_folder = MyLineEdit(self) self.choose_folder.setObjectName("choose_folder") self.choose_folder.clicked.connect(self.slot_choose_folder) self.status = QLabel(self) self.buttonBox = QDialogButtonBox() self.buttonBox.setOrientation(Qt.Orientation.Horizontal) self.buttonBox.setStandardButtons( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setText("提取") self.buttonBox.button( QDialogButtonBox.StandardButton.Cancel).setText("关闭") self.buttonBox.setStyleSheet(btn_style) vbox = QVBoxLayout() hbox_head = QHBoxLayout() hbox_button = QHBoxLayout() hbox_head.addWidget(self.choose_lb) hbox_head.addWidget(self.choose_folder) hbox_button.addWidget(self.buttonBox) vbox.addWidget(self.logo) vbox.addStretch(1) vbox.addWidget(self.status) vbox.addLayout(hbox_head) vbox.addStretch(1) vbox.addLayout(hbox_button) self.setLayout(vbox) self.setMinimumWidth(350) # 设置信号 self.buttonBox.accepted.connect(self.slot_btn_ok) self.buttonBox.rejected.connect(self.slot_btn_no) self.buttonBox.rejected.connect(self.reject)
def initUI(self): 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, 350, 250) self.setWindowTitle('Buttons') self.show()
def App(): app = QApplication(sys.argv) win = QWidget() win.setWindowTitle("PyQt6 QLabel Example") win.left = 100 win.top = 100 l1 = QLabel("Hello World") l2 = QLabel("Welcome to Python GUI Programming") # # Because you can't instantiate a QLable directly with a QPixmap. # l3 = QLabel() l3.setPixmap(QPixmap("python-small.png")) l1.setAlignment(Qt.Alignment.AlignCenter) l2.setAlignment(Qt.Alignment.AlignCenter) l3.setAlignment(Qt.Alignment.AlignCenter) vbox = QVBoxLayout() vbox.addWidget(l1) vbox.addStretch() vbox.addWidget(l2) vbox.addStretch() vbox.addWidget(l3) vbox.addStretch() win.setLayout(vbox) win.show() sys.exit(app.exec())
def setupUI(self): """Setup the main window's GUI.""" # Create the table view widget self.table = QTableView() self.table.setModel(self.contactsModel.model) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.resizeColumnsToContents() # Create buttons self.addButton = QPushButton("Add...") self.addButton.clicked.connect(self.openAddDialog) self.deleteButton = QPushButton("Delete") self.deleteButton.clicked.connect(self.deleteContact) self.clearAllButton = QPushButton("Clear All") self.clearAllButton.clicked.connect(self.clearContacts) # Lay out the GUI layout = QVBoxLayout() layout.addWidget(self.addButton) layout.addWidget(self.deleteButton) layout.addStretch() layout.addWidget(self.clearAllButton) self.layout.addWidget(self.table) self.layout.addLayout(layout)
def setUpMainWindow(self): """Create and arrange widgets in the main window.""" # Create the container widget for each of the pages # in the tab widget self.customer_tab = QWidget() self.orders_tab = QWidget() self.category_tab = QWidget() self.products_tab = QWidget() # Add or insert the tabs into the tab widget self.tabs = QTabWidget() self.tabs.setDocumentMode(True) self.tabs.addTab(self.customer_tab, "Customers") self.tabs.addTab(self.orders_tab, "Orders") self.tabs.addTab(self.category_tab, "Categories") self.tabs.addTab(self.products_tab, "Products") if self.admin_or_not == 1: self.staff_tab = QWidget() self.tabs.insertTab(0, self.staff_tab, "Staff") self.createStaffTab() self.tabs.setCurrentIndex(1) # Set tab to Customers tab self.tabs.currentChanged.connect(self.updateWidgetsAndStates) # Call the methods to construct each page self.createCustomersTab() self.createOrdersTab() self.createCategoriesTab() self.createProductsTab() # Create the widgets in the sidebar for filtering table content self.table_name_label = QLabel("<b>Customers</b>") self.table_name_label.setAlignment(Qt.AlignmentFlag.AlignCenter) self.filter_pattern_line = QLineEdit() self.filter_pattern_line.setClearButtonEnabled(True) self.filter_pattern_line.textChanged.connect(self.filterRegExpChanged) self.filter_regex_combo = QComboBox() filter_options = ["Default", "Wildcard", "Fixed String"] self.filter_regex_combo.addItems(filter_options) self.filter_regex_combo.currentIndexChanged.connect( self.filterRegExpChanged) self.filter_field_combo = QComboBox() self.updateWidgetsAndStates( 1) # Initialize the values in filter_field_combo self.filter_field_combo.currentIndexChanged.connect( self.selectTableColumn) filter_case_sensitivity_cb = QCheckBox("Filter with Case Sensitivity") filter_case_sensitivity_cb.toggled.connect(self.toggleCaseSensitivity) filter_case_sensitivity_cb.toggle() # Layout for the sidebar filter_v_box = QVBoxLayout() filter_v_box.addWidget(self.table_name_label) filter_v_box.addWidget(QLabel("Filter Pattern")) filter_v_box.addWidget(self.filter_pattern_line) filter_v_box.addWidget(QLabel("Filter filter")) filter_v_box.addWidget(self.filter_regex_combo) filter_v_box.addWidget(QLabel("Select Table Column")) filter_v_box.addWidget(self.filter_field_combo) filter_v_box.addWidget(filter_case_sensitivity_cb) filter_v_box.addStretch(2) self.filter_group = QGroupBox("Filtering") self.filter_group.setMaximumWidth(260) self.filter_group.setLayout(filter_v_box) # Arrange the containers in the main window main_h_box = QHBoxLayout() main_h_box.addWidget(self.tabs) main_h_box.addWidget(self.filter_group) main_container = QWidget() main_container.setLayout(main_h_box) self.setCentralWidget(main_container) # Create status bar self.setStatusBar(QStatusBar())
def __init__(self, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) # region Create CartPole instance and load initial settings # Create CartPole instance self.initial_state = create_cartpole_state() self.CartPoleInstance = CartPole(initial_state=self.initial_state) # Set timescales self.CartPoleInstance.dt_simulation = dt_simulation self.CartPoleInstance.dt_controller = controller_update_interval self.CartPoleInstance.dt_save = save_interval # set other settings self.CartPoleInstance.set_controller(controller_init) self.CartPoleInstance.stop_at_90 = stop_at_90_init self.set_random_experiment_generator_init_params() # endregion # region Decide whether to save the data in "CartPole memory" or not self.save_history = save_history_init self.show_experiment_summary = show_experiment_summary_init if self.save_history or self.show_experiment_summary: self.CartPoleInstance.save_data_in_cart = True else: self.CartPoleInstance.save_data_in_cart = False # endregion # region Other variables initial values as provided in gui_default_parameters.py # Start user controlled experiment/ start random experiment/ load and replay - on start button self.simulator_mode = simulator_mode_init self.slider_on_click = slider_on_click_init # Update slider on click/update slider while hoovering over it self.speedup = speedup_init # Default simulation speed-up # endregion # region Initialize loop-timer # This timer allows to relate the simulation time to user time # And (if your computer is fast enough) run simulation # slower or faster than real-time by predefined factor (speedup) self.looper = loop_timer( dt_target=(self.CartPoleInstance.dt_simulation / self.speedup)) # endregion # region Variables controlling the state of various processes (DO NOT MODIFY) self.terminate_experiment_or_replay_thread = False # True: gives signal causing thread to terminate self.pause_experiment_or_replay_thread = False # True: gives signal causing the thread to pause self.run_set_labels_thread = True # True if gauges (labels) keep being repeatedly updated # Stop threads by setting False # Flag indicating if the "START! / STOP!" button should act as start or as stop when pressed. # Can take values "START!" or "STOP!" self.start_or_stop_action = "START!" # Flag indicating whether the pause button should pause or unpause. self.pause_or_unpause_action = "PAUSE" # Flag indicating that saving of experiment recording to csv file has finished self.experiment_or_replay_thread_terminated = False self.user_time_counter = 0 # Measures the user time # Slider instant value (which is draw in GUI) differs from value saved in CartPole instance # if the option updating slider "on-click" is enabled. self.slider_instant_value = self.CartPoleInstance.slider_value self.noise = 'OFF' self.CartPoleInstance.NoiseAdderInstance.noise_mode = self.noise # endregion # region Create GUI Layout # region - Create container for top level layout layout = QVBoxLayout() # endregion # region - Change geometry of the main window self.setGeometry(300, 300, 2500, 1000) # endregion # region - Matplotlib figures (CartPole drawing and Slider) # Draw Figure self.fig = Figure( figsize=(25, 10) ) # Regulates the size of Figure in inches, before scaling to window size. self.canvas = FigureCanvas(self.fig) self.fig.AxCart = self.canvas.figure.add_subplot(211) self.fig.AxSlider = self.canvas.figure.add_subplot(212) self.fig.AxSlider.set_ylim(0, 1) self.CartPoleInstance.draw_constant_elements(self.fig, self.fig.AxCart, self.fig.AxSlider) # Attach figure to the layout lf = QVBoxLayout() lf.addWidget(self.canvas) # endregion # region - Radio buttons selecting current controller self.rbs_controllers = [] for controller_name in self.CartPoleInstance.controller_names: self.rbs_controllers.append(QRadioButton(controller_name)) # Ensures that radio buttons are exclusive self.controllers_buttons_group = QButtonGroup() for button in self.rbs_controllers: self.controllers_buttons_group.addButton(button) lr_c = QVBoxLayout() lr_c.addStretch(1) for rb in self.rbs_controllers: rb.clicked.connect(self.RadioButtons_controller_selection) lr_c.addWidget(rb) lr_c.addStretch(1) self.rbs_controllers[self.CartPoleInstance.controller_idx].setChecked( True) # endregion # region - Create central part of the layout for figures and radio buttons and add it to the whole layout lc = QHBoxLayout() lc.addLayout(lf) lc.addLayout(lr_c) layout.addLayout(lc) # endregion # region - Gauges displaying current values of various states and parameters (time, velocity, angle,...) # First row ld = QHBoxLayout() # User time self.labTime = QLabel("User's time (s): ") self.timer = QTimer() self.timer.setInterval(100) # Tick every 1/10 of the second self.timer.timeout.connect(self.set_user_time_label) self.timer.start() ld.addWidget(self.labTime) # Speed, angle, motor power (Q) self.labSpeed = QLabel('Speed (m/s):') self.labAngle = QLabel('Angle (deg):') self.labMotor = QLabel('') self.labTargetPosition = QLabel('') ld.addWidget(self.labSpeed) ld.addWidget(self.labAngle) ld.addWidget(self.labMotor) ld.addWidget(self.labTargetPosition) layout.addLayout(ld) # Second row of labels # Simulation time, Measured (real) speed-up, slider-value ld2 = QHBoxLayout() self.labTimeSim = QLabel('Simulation Time (s):') ld2.addWidget(self.labTimeSim) self.labSpeedUp = QLabel('Speed-up (measured):') ld2.addWidget(self.labSpeedUp) self.labSliderInstant = QLabel('') ld2.addWidget(self.labSliderInstant) layout.addLayout(ld2) # endregion # region - Buttons "START!" / "STOP!", "PAUSE", "QUIT" self.bss = QPushButton("START!") self.bss.pressed.connect(self.start_stop_button) self.bp = QPushButton("PAUSE") self.bp.pressed.connect(self.pause_unpause_button) bq = QPushButton("QUIT") bq.pressed.connect(self.quit_application) lspb = QHBoxLayout() # Sub-Layout for Start/Stop and Pause Buttons lspb.addWidget(self.bss) lspb.addWidget(self.bp) # endregion # region - Sliders setting initial state and buttons for kicking the pole # Sliders setting initial position and angle lb = QVBoxLayout() # Layout for buttons lb.addLayout(lspb) lb.addWidget(bq) ip = QHBoxLayout() # Layout for initial position sliders self.initial_position_slider = QSlider( orientation=Qt.Orientation.Horizontal) self.initial_position_slider.setRange( -int(float(1000 * TrackHalfLength)), int(float(1000 * TrackHalfLength))) self.initial_position_slider.setValue(0) self.initial_position_slider.setSingleStep(1) self.initial_position_slider.valueChanged.connect( self.update_initial_position) self.initial_angle_slider = QSlider( orientation=Qt.Orientation.Horizontal) self.initial_angle_slider.setRange(-int(float(100 * np.pi)), int(float(100 * np.pi))) self.initial_angle_slider.setValue(0) self.initial_angle_slider.setSingleStep(1) self.initial_angle_slider.valueChanged.connect( self.update_initial_angle) ip.addWidget(QLabel("Initial position:")) ip.addWidget(self.initial_position_slider) ip.addWidget(QLabel("Initial angle:")) ip.addWidget(self.initial_angle_slider) ip.addStretch(0.01) # Slider setting latency self.LATENCY_SLIDER_RANGE_INT = 1000 self.latency_slider = QSlider(orientation=Qt.Orientation.Horizontal) self.latency_slider.setRange(0, self.LATENCY_SLIDER_RANGE_INT) self.latency_slider.setValue( int(self.CartPoleInstance.LatencyAdderInstance.latency * self.LATENCY_SLIDER_RANGE_INT / self.CartPoleInstance.LatencyAdderInstance.max_latency)) self.latency_slider.setSingleStep(1) self.latency_slider.valueChanged.connect(self.update_latency) ip.addWidget(QLabel("Latency:")) ip.addWidget(self.latency_slider) self.labLatency = QLabel('Latency (ms): {:.1f}'.format( self.CartPoleInstance.LatencyAdderInstance.latency * 1000)) ip.addWidget(self.labLatency) # Buttons activating noise self.rbs_noise = [] for mode_name in ['ON', 'OFF']: self.rbs_noise.append(QRadioButton(mode_name)) # Ensures that radio buttons are exclusive self.noise_buttons_group = QButtonGroup() for button in self.rbs_noise: self.noise_buttons_group.addButton(button) lr_n = QHBoxLayout() lr_n.addWidget(QLabel('Noise:')) for rb in self.rbs_noise: rb.clicked.connect(self.RadioButtons_noise_on_off) lr_n.addWidget(rb) self.rbs_noise[1].setChecked(True) ip.addStretch(0.01) ip.addLayout(lr_n) ip.addStretch(0.01) # Buttons giving kick to the pole kick_label = QLabel("Kick pole:") kick_left_button = QPushButton() kick_left_button.setText("Left") kick_left_button.adjustSize() kick_left_button.clicked.connect(self.kick_pole) kick_right_button = QPushButton() kick_right_button.setText("Right") kick_right_button.adjustSize() kick_right_button.clicked.connect(self.kick_pole) ip.addWidget(kick_label) ip.addWidget(kick_left_button) ip.addWidget(kick_right_button) lb.addLayout(ip) layout.addLayout(lb) # endregion # region - Text boxes and Combobox to provide settings concerning generation of random experiment l_generate_trace = QHBoxLayout() l_generate_trace.addWidget(QLabel('Random experiment settings:')) l_generate_trace.addWidget(QLabel('Length (s):')) self.textbox_length = QLineEdit() l_generate_trace.addWidget(self.textbox_length) l_generate_trace.addWidget(QLabel('Turning Points (m):')) self.textbox_turning_points = QLineEdit() l_generate_trace.addWidget(self.textbox_turning_points) l_generate_trace.addWidget(QLabel('Interpolation:')) self.cb_interpolation = QComboBox() self.cb_interpolation.addItems( ['0-derivative-smooth', 'linear', 'previous']) self.cb_interpolation.currentIndexChanged.connect( self.cb_interpolation_selectionchange) self.cb_interpolation.setCurrentText( self.CartPoleInstance.interpolation_type) l_generate_trace.addWidget(self.cb_interpolation) layout.addLayout(l_generate_trace) # endregion # region - Textbox to provide csv file name for saving or loading data l_text = QHBoxLayout() textbox_title = QLabel('CSV file name:') self.textbox = QLineEdit() l_text.addWidget(textbox_title) l_text.addWidget(self.textbox) layout.addLayout(l_text) # endregion # region - Make strip of layout for checkboxes l_cb = QHBoxLayout() # endregion # region - Textbox to provide the target speed-up value l_text_speedup = QHBoxLayout() tx_speedup_title = QLabel('Speed-up (target):') self.tx_speedup = QLineEdit() l_text_speedup.addWidget(tx_speedup_title) l_text_speedup.addWidget(self.tx_speedup) self.tx_speedup.setText(str(self.speedup)) l_cb.addLayout(l_text_speedup) self.wrong_speedup_msg = QMessageBox() self.wrong_speedup_msg.setWindowTitle("Speed-up value problem") self.wrong_speedup_msg.setIcon(QMessageBox.Icon.Critical) # endregion # region - Checkboxes # region -- Checkbox: Save/don't save experiment recording self.cb_save_history = QCheckBox('Save results', self) if self.save_history: self.cb_save_history.toggle() self.cb_save_history.toggled.connect(self.cb_save_history_f) l_cb.addWidget(self.cb_save_history) # endregion # region -- Checkbox: Display plots showing dynamic evolution of the system as soon as experiment terminates self.cb_show_experiment_summary = QCheckBox('Show experiment summary', self) if self.show_experiment_summary: self.cb_show_experiment_summary.toggle() self.cb_show_experiment_summary.toggled.connect( self.cb_show_experiment_summary_f) l_cb.addWidget(self.cb_show_experiment_summary) # endregion # region -- Checkbox: Block pole if it reaches +/-90 deg self.cb_stop_at_90_deg = QCheckBox('Stop-at-90-deg', self) if self.CartPoleInstance.stop_at_90: self.cb_stop_at_90_deg.toggle() self.cb_stop_at_90_deg.toggled.connect(self.cb_stop_at_90_deg_f) l_cb.addWidget(self.cb_stop_at_90_deg) # endregion # region -- Checkbox: Update slider on click/update slider while hoovering over it self.cb_slider_on_click = QCheckBox('Update slider on click', self) if self.slider_on_click: self.cb_slider_on_click.toggle() self.cb_slider_on_click.toggled.connect(self.cb_slider_on_click_f) l_cb.addWidget(self.cb_slider_on_click) # endregion # endregion # region - Radio buttons selecting simulator mode: user defined experiment, random experiment, replay # List available simulator modes - constant self.available_simulator_modes = [ 'Slider-Controlled Experiment', 'Random Experiment', 'Replay' ] self.rbs_simulator_mode = [] for mode_name in self.available_simulator_modes: self.rbs_simulator_mode.append(QRadioButton(mode_name)) # Ensures that radio buttons are exclusive self.simulator_mode_buttons_group = QButtonGroup() for button in self.rbs_simulator_mode: self.simulator_mode_buttons_group.addButton(button) lr_sm = QHBoxLayout() lr_sm.addStretch(1) lr_sm.addWidget(QLabel('Simulator mode:')) for rb in self.rbs_simulator_mode: rb.clicked.connect(self.RadioButtons_simulator_mode) lr_sm.addWidget(rb) lr_sm.addStretch(1) self.rbs_simulator_mode[self.available_simulator_modes.index( self.simulator_mode)].setChecked(True) l_cb.addStretch(1) l_cb.addLayout(lr_sm) l_cb.addStretch(1) # endregion # region - Add checkboxes to layout layout.addLayout(l_cb) # endregion # region - Create an instance of a GUI window w = QWidget() w.setLayout(layout) self.setCentralWidget(w) self.show() self.setWindowTitle('CartPole Simulator') # endregion # endregion # region Open controller-specific popup windows self.open_additional_controller_widget() # endregion # region Activate functions capturing mouse movements and clicks over the slider # This line links function capturing the mouse position on the canvas of the Figure self.canvas.mpl_connect("motion_notify_event", self.on_mouse_movement) # This line links function capturing the mouse position on the canvas of the Figure click self.canvas.mpl_connect("button_press_event", self.on_mouse_click) # endregion # region Introducing multithreading # To ensure smooth functioning of the app, # the calculations and redrawing of the figures have to be done in a different thread # than the one capturing the mouse position and running the animation self.threadpool = QThreadPool() # endregion # region Starts a thread repeatedly redrawing gauges (labels) of the GUI # It runs till the QUIT button is pressed worker_labels = Worker(self.set_labels_thread) self.threadpool.start(worker_labels) # endregion # region Start animation repeatedly redrawing changing elements of matplotlib figures (CartPole drawing and slider) # This animation runs ALWAYS when the GUI is open # The buttons of GUI only decide if new parameters are calculated or not self.anim = self.CartPoleInstance.run_animation(self.fig)
class MyWidget(QWidget): def __init__(self): super(MyWidget, self).__init__() self.setFixedSize(620, 600) self.setWindowTitle("自动画流程图工具 version:1.0.0 ") self.laytout = QVBoxLayout(self) headwidget = QWidget(self) headlayout = QHBoxLayout() label01 = QLabel(" ID ") label02 = QLabel("流程图内容") label03 = QLabel("节点类型") label04 = QLabel("X坐标") label05 = QLabel("Y坐标") label06 = QLabel("link1") label07 = QLabel('link2') headlayout.addWidget(label01, 3) headlayout.addWidget(label02, 40) headlayout.addWidget(label03, 8) headlayout.addWidget(label04, 3) headlayout.addWidget(label05, 3) headlayout.addWidget(label06, 3) headlayout.addWidget(label07, 3) headlayout.addStretch() headlayout.setContentsMargins(0, 0, 0, 0) headwidget.setLayout(headlayout) btnwidget = QWidget() btnlayout = QHBoxLayout() self.add_btn = QPushButton("添加节点") self.start_btn = QPushButton("开始画图") btnlayout.addWidget(self.add_btn) btnlayout.addWidget(self.start_btn) btnwidget.setLayout(btnlayout) btnlayout.setContentsMargins(0, 0, 0, 0) self.laytout.addStretch() self.laytout.addWidget(btnwidget) self.laytout.addWidget(headwidget) #self.laytout.addStretch() self.add_btn.clicked.connect(self.add_node) self.start_btn.clicked.connect(self.start_draw_visiflow) self.nodes = [] self.id = 0 def add_node(self): node = NodeWidget(self.id) self.laytout.addWidget(node) self.nodes.append(node) #self.laytout.addStretch() self.id += 1 #print("添加节点") def start_draw_visiflow(self): data = [] for node in self.nodes: data.append(node.get_node_info()) print(data) obj = VisioDraw(os.getcwd() + '\\2.vsdx', autoquit=False) obj.open() obj.new_page('第一页') obj.draw_table(data) obj.save()
def initUI(self): self.setWindowTitle("设置") logo = QLabel() logo.setPixmap(QPixmap(SRC_DIR + "logo2.gif")) logo.setStyleSheet("background-color:rgb(255,255,255);") logo.setAlignment(Qt.AlignmentFlag.AlignCenter) self.download_threads_lb = QLabel("同时下载文件数") self.download_threads_var = QLineEdit() self.download_threads_var.setPlaceholderText("范围:1-9") self.download_threads_var.setToolTip("范围:1-9") self.download_threads_var.setInputMask("D") self.max_size_lb = QLabel("分卷大小(MB)") self.max_size_var = QLineEdit() self.max_size_var.setPlaceholderText("普通用户最大100,vip用户根据具体情况设置") self.max_size_var.setToolTip("普通用户最大100,vip用户根据具体情况设置") self.max_size_var.setInputMask("D99") self.timeout_lb = QLabel("请求超时(秒)") self.timeout_var = QLineEdit() self.timeout_var.setPlaceholderText("范围:1-99") self.timeout_var.setToolTip("范围:1-99") self.timeout_var.setInputMask("D9") self.upload_delay_lb = QLabel("上传延时(秒)") self.upload_delay_var = QLineEdit() self.upload_delay_var.setPlaceholderText("范围:1-99") self.upload_delay_var.setToolTip("范围:1-99") self.upload_delay_var.setInputMask("D9") self.dl_path_lb = QLabel("下载保存路径") self.dl_path_var = MyLineEdit(self) self.dl_path_var.clicked.connect(self.set_download_path) self.time_fmt_box = QCheckBox("使用[年-月-日]时间格式") self.time_fmt_box.setToolTip("文件上传日期显示格式") self.to_tray_box = QCheckBox("关闭到系统托盘") self.to_tray_box.setToolTip("点击关闭软件按钮是最小化软件至系统托盘") self.watch_clipboard_box = QCheckBox("监听系统剪切板") self.watch_clipboard_box.setToolTip("检测到系统剪切板中有符合规范的蓝奏链接时自动唤起软件,并提取") self.debug_box = QCheckBox("开启调试日志") self.debug_box.setToolTip("记录软件 debug 信息至 debug-lanzou-gui.log 文件") self.set_pwd_box = QCheckBox("上传文件自动设置密码") self.set_pwd_var = AutoResizingTextEdit() self.set_pwd_var.setPlaceholderText(" 2-8 位数字或字母") self.set_pwd_var.setToolTip("2-8 位数字或字母") self.set_desc_box = QCheckBox("上传文件自动设置描述") self.set_desc_var = AutoResizingTextEdit() self.big_file_box = QCheckBox(f"允许上传超过 {self.max_size}MB 的大文件") self.big_file_box.setToolTip("开启大文件上传支持 (功能下线)") self.upgrade_box = QCheckBox("自动检测新版本") self.upgrade_box.setToolTip("在软件打开时自动检测是否有新的版本发布,如有则弹出更新信息") self.time_fmt_box.toggle() self.time_fmt_box.stateChanged.connect(self.change_time_fmt) self.to_tray_box.stateChanged.connect(self.change_to_tray) self.watch_clipboard_box.stateChanged.connect(self.change_watch_clipboard) self.debug_box.stateChanged.connect(self.change_debug) self.set_pwd_box.stateChanged.connect(self.change_set_pwd) self.set_pwd_var.editingFinished.connect(self.check_pwd) self.set_desc_box.stateChanged.connect(self.change_set_desc) self.big_file_box.stateChanged.connect(self.change_big_file) self.upgrade_box.stateChanged.connect(self.change_upgrade) buttonBox = QDialogButtonBox() buttonBox.setOrientation(Qt.Orientation.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.StandardButton.Reset | QDialogButtonBox.StandardButton.Save | QDialogButtonBox.StandardButton.Cancel) buttonBox.button(QDialogButtonBox.StandardButton.Reset).setText("重置") buttonBox.button(QDialogButtonBox.StandardButton.Save).setText("保存") buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setText("取消") buttonBox.button(QDialogButtonBox.StandardButton.Reset).clicked.connect(lambda: self.set_values(reset=True)) buttonBox.button(QDialogButtonBox.StandardButton.Save).clicked.connect(self.slot_save) buttonBox.rejected.connect(self.reject) form = QFormLayout() form.setLabelAlignment(Qt.AlignmentFlag.AlignRight) form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) # 覆盖MacOS的默认样式 form.setSpacing(10) form.addRow(self.download_threads_lb, self.download_threads_var) form.addRow(self.timeout_lb, self.timeout_var) form.addRow(self.upload_delay_lb, self.upload_delay_var) form.addRow(self.max_size_lb, self.max_size_var) form.addRow(self.dl_path_lb, self.dl_path_var) vbox = QVBoxLayout() vbox.addWidget(logo) vbox.addStretch(1) vbox.addLayout(form) vbox.addStretch(1) hbox = QHBoxLayout() hbox.addWidget(self.time_fmt_box) hbox.addWidget(self.to_tray_box) hbox.addWidget(self.watch_clipboard_box) hbox.addWidget(self.debug_box) vbox.addLayout(hbox) vbox.addStretch(1) hbox_2 = QHBoxLayout() hbox_2.addWidget(self.set_pwd_box) hbox_2.addWidget(self.set_pwd_var) vbox.addLayout(hbox_2) vbox.addStretch(1) hbox_3 = QHBoxLayout() hbox_3.addWidget(self.set_desc_box) hbox_3.addWidget(self.set_desc_var) vbox.addLayout(hbox_3) hbox_4 = QHBoxLayout() hbox_4.addWidget(self.big_file_box) hbox_4.addWidget(self.upgrade_box) vbox.addStretch(1) vbox.addLayout(hbox_4) vbox.addStretch(2) vbox.addWidget(buttonBox) self.setLayout(vbox) self.setMinimumWidth(500)
def initUI(self): self.setWindowIcon(QIcon(SRC_DIR + "share.ico")) self.setWindowTitle("文件信息") self.buttonBox = QDialogButtonBox() self.buttonBox.setOrientation(Qt.Orientation.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.StandardButton.Close) self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setText("关闭") self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.clean) self.buttonBox.rejected.connect(self.closed.emit) self.logo = QLabel() self.logo.setPixmap(QPixmap(SRC_DIR + "q9.gif")) self.logo.setAlignment(Qt.AlignmentFlag.AlignCenter) self.logo.setStyleSheet("background-color:rgb(255,204,51);") self.lb_name = QLabel() self.lb_name.setText("文件名:") self.tx_name = AutoResizingTextEdit() self.tx_name.setReadOnly(True) self.tx_name.setMinimumLines(1) self.lb_size = QLabel() self.lb_size.setText("文件大小:") self.tx_size = QLabel() self.lb_time = QLabel() self.lb_time.setText("上传时间:") self.tx_time = QLabel() self.lb_dl_count = QLabel() self.lb_dl_count.setText("下载次数:") self.tx_dl_count = QLabel() self.lb_share_url = QLabel() self.lb_share_url.setText("分享链接:") self.tx_share_url = QLineEdit() self.tx_share_url.setReadOnly(True) self.lb_pwd = QLabel() self.lb_pwd.setText("提取码:") self.tx_pwd = QLineEdit() self.tx_pwd.setReadOnly(True) self.lb_short = QLabel() self.lb_short.setText("短链接:") self.tx_short = AutoResizingTextEdit(self) self.tx_short.setPlaceholderText("单击获取") self.tx_short.clicked.connect(self.call_get_short_url) self.tx_short.setReadOnly(True) self.tx_short.setMinimumLines(1) self.lb_desc = QLabel() self.lb_desc.setText("文件描述:") self.tx_desc = AutoResizingTextEdit() self.tx_desc.setReadOnly(True) self.tx_desc.setMinimumLines(1) self.lb_dl_link = QLabel() self.lb_dl_link.setText("下载直链:") self.tx_dl_link = AutoResizingTextEdit(self) self.tx_dl_link.setPlaceholderText("单击获取") self.tx_dl_link.clicked.connect(self.call_get_dl_link) self.tx_dl_link.setReadOnly(True) self.tx_dl_link.setMinimumLines(1) vbox = QVBoxLayout() vbox.addWidget(self.logo) vbox.addStretch(1) form = QFormLayout() form.setLabelAlignment(Qt.AlignmentFlag.AlignRight) form.addRow(self.lb_name, self.tx_name) form.addRow(self.lb_size, self.tx_size) form.addRow(self.lb_time, self.tx_time) form.addRow(self.lb_dl_count, self.tx_dl_count) form.addRow(self.lb_share_url, self.tx_share_url) form.addRow(self.lb_pwd, self.tx_pwd) form.addRow(self.lb_short, self.tx_short) form.addRow(self.lb_desc, self.tx_desc) form.addRow(self.lb_dl_link, self.tx_dl_link) form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) # 覆盖MacOS的默认样式 vbox.addLayout(form) vbox.addStretch(1) vbox.addWidget(self.buttonBox) self.setLayout(vbox) self.setMinimumWidth(500)
def initUI(self): self.setWindowTitle("登录蓝奏云") self.setWindowIcon(QIcon(SRC_DIR + "login.ico")) logo = QLabel() logo.setPixmap(QPixmap(SRC_DIR + "logo3.gif")) logo.setStyleSheet("background-color:rgb(0,153,255);") logo.setAlignment(Qt.AlignmentFlag.AlignCenter) self.tabs = QTabWidget() self.auto_tab = QWidget() self.hand_tab = QWidget() # Add tabs self.tabs.addTab(self.auto_tab,"自动获取Cookie") self.tabs.addTab(self.hand_tab,"手动输入Cookie") self.auto_get_cookie_ok = AutoResizingTextEdit("🔶点击👇自动获取浏览器登录信息👇") self.auto_get_cookie_ok.setReadOnly(True) self.auto_get_cookie_btn = QPushButton("自动读取浏览器登录信息") auto_cookie_notice = '支持浏览器:Chrome, Chromium, Opera, Edge, Firefox' self.auto_get_cookie_btn.setToolTip(auto_cookie_notice) self.auto_get_cookie_btn.clicked.connect(self.call_auto_get_cookie) self.auto_get_cookie_btn.setStyleSheet("QPushButton {min-width: 210px;max-width: 210px;}") self.name_lb = QLabel("&U 用户") self.name_lb.setAlignment(Qt.AlignmentFlag.AlignCenter) self.name_ed = QLineEdit() self.name_lb.setBuddy(self.name_ed) self.pwd_lb = QLabel("&P 密码") self.pwd_lb.setAlignment(Qt.AlignmentFlag.AlignCenter) self.pwd_ed = QLineEdit() self.pwd_ed.setEchoMode(QLineEdit.EchoMode.Password) self.pwd_lb.setBuddy(self.pwd_ed) self.cookie_lb = QLabel("&Cookie") self.cookie_ed = QTextEdit() notice = "由于滑动验证的存在,需要输入cookie,cookie请使用浏览器获取\n" + \ "cookie会保存在本地,下次使用。其格式如下:\n ylogin=value1; phpdisk_info=value2" self.cookie_ed.setPlaceholderText(notice) self.cookie_lb.setBuddy(self.cookie_ed) self.show_input_cookie_btn = QPushButton("显示Cookie输入框") self.show_input_cookie_btn.setToolTip(notice) self.show_input_cookie_btn.setStyleSheet("QPushButton {min-width: 110px;max-width: 110px;}") self.show_input_cookie_btn.clicked.connect(self.change_show_input_cookie) self.ok_btn = QPushButton("登录") self.ok_btn.clicked.connect(self.change_ok_btn) self.cancel_btn = QPushButton("取消") self.cancel_btn.clicked.connect(self.change_cancel_btn) lb_line_1 = QLabel() lb_line_1.setText('<html><hr />切换用户</html>') lb_line_2 = QLabel() lb_line_2.setText('<html><hr /></html>') self.form = QFormLayout() self.form.setLabelAlignment(Qt.AlignmentFlag.AlignRight) self.form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) # 覆盖MacOS的默认样式 self.form.addRow(self.name_lb, self.name_ed) self.form.addRow(self.pwd_lb, self.pwd_ed) if is_windows: def set_assister_path(): """设置辅助登录程序路径""" assister_path = QFileDialog.getOpenFileName(self, "选择辅助登录程序路径", self._cwd, "EXE Files (*.exe)") if not assister_path[0]: return None assister_path = os.path.normpath(assister_path[0]) # windows backslash if assister_path == self._cookie_assister: return None self.assister_ed.setText(assister_path) self._cookie_assister = assister_path self.assister_lb = QLabel("登录辅助程序") self.assister_lb.setAlignment(Qt.AlignmentFlag.AlignCenter) self.assister_ed = MyLineEdit(self) self.assister_ed.setText(self._cookie_assister) self.assister_ed.clicked.connect(set_assister_path) self.assister_lb.setBuddy(self.assister_ed) self.form.addRow(self.assister_lb, self.assister_ed) hbox = QHBoxLayout() hbox.addWidget(self.show_input_cookie_btn) hbox.addStretch(1) hbox.addWidget(self.ok_btn) hbox.addWidget(self.cancel_btn) user_box = QHBoxLayout() self.user_num = 0 self.user_btns = {} for user in self._config.users_name: user = str(user) # TODO: 可能需要删掉 self.user_btns[user] = QDoublePushButton(user) self.user_btns[user].setStyleSheet("QPushButton {border:none;}") if user == self._config.name: self.user_btns[user].setStyleSheet("QPushButton {background-color:rgb(0,153,2);}") self.tabs.setCurrentIndex(1) self.user_btns[user].setToolTip(f"点击选中,双击切换至用户:{user}") self.user_btns[user].doubleClicked.connect(self.choose_user) self.user_btns[user].clicked.connect(self.delete_chose_user) user_box.addWidget(self.user_btns[user]) self.user_num += 1 user_box.addStretch(1) self.layout = QVBoxLayout(self) self.layout.addWidget(logo) vbox = QVBoxLayout() if self._config.name: vbox.addWidget(lb_line_1) user_box.setAlignment(Qt.AlignmentFlag.AlignCenter) vbox.addLayout(user_box) vbox.addWidget(lb_line_2) if self.user_num > 1: self.del_user_btn = QPushButton("删除账户") self.del_user_btn.setIcon(QIcon(SRC_DIR + "delete.ico")) self.del_user_btn.setStyleSheet("QPushButton {min-width: 180px;max-width: 180px;}") self.del_user_btn.clicked.connect(self.call_del_chose_user) vbox.addWidget(self.del_user_btn) else: self.del_user_btn = None vbox.addStretch(1) vbox.addLayout(self.form) vbox.addStretch(1) vbox.addLayout(hbox) vbox.setAlignment(Qt.AlignmentFlag.AlignCenter) self.hand_tab.setLayout(vbox) auto_cookie_vbox = QVBoxLayout() auto_cookie_vbox.addWidget(self.auto_get_cookie_ok) auto_cookie_vbox.addWidget(self.auto_get_cookie_btn) auto_cookie_vbox.setAlignment(Qt.AlignmentFlag.AlignCenter) self.auto_tab.setLayout(auto_cookie_vbox) self.layout.addWidget(self.tabs) self.setLayout(self.layout) self.update_selection(self._config.name)
def initUI(self): self.setWindowTitle("关于 lanzou-gui") about = f'本项目使用PyQt6实现图形界面,可以完成蓝奏云的大部分功能<br/> \ 得益于 <a href="{self._api_url}">API</a> 的功能,可以间接突破单文件最大 100MB 的限制,同时增加了批量上传/下载的功能<br/> \ Python 依赖见<a href="{self._github }/blob/master/requirements.txt">requirements.txt</a>,\ <a href="{self._github}/releases">releases</a> 有打包好了的 Windows 可执行程序,但可能不是最新的' project_url = f'<a href="{self._home_page}">主页</a> | <a href="{self._github}">repo</a> | \ <a href="{self._gitee}">mirror repo</a>' self.logo = QLabel() # logo self.logo.setPixmap(QPixmap(SRC_DIR + "logo2.gif")) self.logo.setStyleSheet("background-color:rgb(255,255,255);") self.logo.setAlignment(Qt.AlignmentFlag.AlignCenter) self.lb_qt_ver = QLabel("依赖") # QT 版本 self.lb_qt_text = QLabel( f"QT: {QT_VERSION_STR}, PyQt: {PYQT_VERSION_STR}") # QT 版本 self.lb_name = QLabel("版本") # 版本 self.lb_name_text = QPushButton("") # 版本 self.lb_name_text.setToolTip("点击检查更新") ver_style = "QPushButton {border:none; background:transparent;font-weight:bold;color:blue;}" self.lb_name_text.setStyleSheet(ver_style) self.lb_name_text.clicked.connect( lambda: self.check_update.emit(self._ver, True)) self.lb_about = QLabel("关于") # about self.lb_about_text = QLabel() self.lb_about_text.setText(about) self.lb_about_text.setOpenExternalLinks(True) self.lb_author = QLabel("作者") # author self.lb_author_mail = QLabel( "<a href='mailto:[email protected]'>rachpt</a>") self.lb_author_mail.setOpenExternalLinks(True) self.lb_update = QLabel("项目") # 更新 self.lb_update_url = QLabel(project_url) self.lb_update_url.setOpenExternalLinks(True) self.buttonBox = QDialogButtonBox() self.buttonBox.setOrientation(Qt.Orientation.Horizontal) self.buttonBox.setStandardButtons( QDialogButtonBox.StandardButton.Close) self.buttonBox.button( QDialogButtonBox.StandardButton.Close).setText("关闭") self.buttonBox.rejected.connect(self.reject) self.buttonBox.setStyleSheet(btn_style) self.recommend = QLabel( "<br />大文件推荐使用 <a href='https://github.com/Aruelius/cloud189'>cloud189-cli</a>" ) self.recommend.setOpenExternalLinks(True) self.line = QLine(QPoint(), QPoint(550, 0)) self.lb_line = QLabel('<html><hr /></html>') vbox = QVBoxLayout() vbox.addWidget(self.logo) vbox.addStretch(1) self.form = QFormLayout() self.form.setLabelAlignment(Qt.AlignmentFlag.AlignRight) self.form.setFormAlignment(Qt.AlignmentFlag.AlignLeft) self.form.setHorizontalSpacing(40) self.form.setVerticalSpacing(15) self.form.addRow(self.lb_qt_ver, self.lb_qt_text) self.form.addRow(self.lb_name, self.lb_name_text) self.form.addRow(self.lb_update, self.lb_update_url) self.form.addRow(self.lb_author, self.lb_author_mail) self.form.addRow(self.lb_about, self.lb_about_text) self.form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy. AllNonFixedFieldsGrow) # 覆盖MacOS的默认样式 vbox.addLayout(self.form) vbox.addStretch(1) vbox.addWidget(self.recommend) vbox.addWidget(self.lb_line) donate = QLabel() donate.setText("<b>捐助我</b> 如果你愿意") donate.setAlignment(Qt.AlignmentFlag.AlignCenter) hbox = QHBoxLayout() hbox.addStretch(2) for it in ["wechat", "alipay", "qqpay"]: lb = QLabel() lb.setPixmap(QPixmap(SRC_DIR + f"{it}.jpg")) hbox.addWidget(lb) hbox.addStretch(1) hbox.addWidget(self.buttonBox) vbox.addWidget(donate) vbox.addLayout(hbox) self.setLayout(vbox) self.setMinimumWidth(720)