From c2333af67c6b8182edd6af5a7adebc7d0d4b8a30 Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Thu, 22 Feb 2024 22:28:14 +0800 Subject: [PATCH] =?UTF-8?q?pyside6=E5=AD=A6=E4=B9=A0=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/guipanel.py | 65 +++++++--------------------------------------- 1 file changed, 9 insertions(+), 56 deletions(-) diff --git a/工具v2/guipanel.py b/工具v2/guipanel.py index ea53ac22..2843cf7d 100644 --- a/工具v2/guipanel.py +++ b/工具v2/guipanel.py @@ -1,61 +1,14 @@ -import sys -from PySide6.QtWidgets import QApplication, QMainWindow, QMenu, QVBoxLayout, QWidget, QLineEdit -from PySide6.QtGui import QAction +from PySide6.QtWidgets import QMainWindow, QApplication, QLabel class MyWindow(QMainWindow): def __init__(self): super().__init__() + lbl = QLabel("按钮", self) + lbl.setGeometry(100,100,200,100) + lbl.setText("重新设置按钮文字") - self.setWindowTitle("Menu Example") - self.resize(800, 600) - - # Create a menu bar - menu_bar = self.menuBar() - - # Create "File" menu - file_menu = menu_bar.addMenu("File") - - # Create "Filter" action - filter_action = QAction("Filter", self) - filter_action.triggered.connect(self.show_text_boxes) - file_menu.addAction(filter_action) - - # Create "Generate" action - generate_action = QAction("Generate", self) - file_menu.addAction(generate_action) - - # Create "Exit" action - exit_action = QAction("Exit", self) - exit_action.triggered.connect(self.close) - menu_bar.addAction(exit_action) - - self.central_widget = QWidget() - self.setCentralWidget(self.central_widget) - self.layout = QVBoxLayout(self.central_widget) - - def show_text_boxes(self): - self.clear_layout() - - content_textbox = QLineEdit(self) - content_textbox.setPlaceholderText("Content") - self.layout.addWidget(content_textbox) - - obj_textbox = QLineEdit(self) - obj_textbox.setPlaceholderText("Obj") - self.layout.addWidget(obj_textbox) - - tag_textbox = QLineEdit(self) - tag_textbox.setPlaceholderText("Tag") - self.layout.addWidget(tag_textbox) - - def clear_layout(self): - for i in reversed(range(self.layout.count())): - widget = self.layout.itemAt(i).widget() - if widget is not None: - widget.deleteLater() - -if __name__ == "__main__": - app = QApplication(sys.argv) - window = MyWindow() - window.show() - sys.exit(app.exec()) \ No newline at end of file +if __name__ == '__main__': + app = QApplication([]) + windows = MyWindow() + windows.show() + app.exec() \ No newline at end of file