我的账户
啄木鸟学院

专注软件测试菁英教育

亲爱的游客,欢迎!

已有账号,请

如尚未注册?

python_张国荣_2021.01.27

[复制链接]
淰7331学员认证 发表于 2021-1-27 20:10:35 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
本帖最后由 淰7331 于 2021-1-27 20:10 编辑

from PyQt5.QtWidgets import QApplication,QWidget,QLabel,QLineEdit,QTextEdit,QGridLayout
import sys

class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        grid = QGridLayout()
        self.setLayout(grid)

        title = QLabel('标题:')
        title_edit = QLineEdit()

        author = QLabel('作者:')
        author_edit = QLineEdit()

        content = QLabel('正文:')
        content_edit = QTextEdit()

        grid.addWidget(title,1,1)
        grid.addWidget(title_edit,1,2)
        grid.addWidget(author,2,1)
        grid.addWidget(author_edit,2,2)
        grid.addWidget(content,3,1)
        grid.addWidget(content_edit,3,2)

        self.setGeometry(300,300,300,250)
        self.setWindowTitle('文本编辑器')
        self.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

from PyQt5.QtWidgets import QApplication,QMainWindow
import sys,time

class Example(QMainWindow):

    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        # 创建状态栏
        status = self.statusBar()
        # 在状态栏显示信息
        status.showMessage('准备好了!')
        self.setGeometry(300,300,300,200)
        self.setWindowTitle('状态栏')
        self.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
from PyQt5.QtWidgets import QApplication,QMainWindow,qApp,QAction
from PyQt5.QtGui import QIcon
import sys

class Example(QMainWindow):

    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        # 创建一个菜单条目
        exitAction = QAction(QIcon('python\day09\exit3.png'),'退出',self)
        # 添加快捷键
        exitAction.setShortcut('Ctrl+Q')
        # 添加一个提示
        exitAction.setStatusTip('退出程序!')
        # 给菜单条目添加动作
        exitAction.triggered.connect(qApp.quit)

        # 创建一个菜单栏
        menuBar = self.menuBar()
        # 添加一个File菜单
        fileMenu = menuBar.addMenu('File')
        # 添加菜单条目
        fileMenu.addAction(exitAction)

        editMenu = menuBar.addMenu('Edit')
        editMenu.addAction(exitAction)

        self.setGeometry(300,300,300,200)
        self.setWindowTitle('程序菜单')
        self.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
from PyQt5.QtWidgets import QApplication,QMainWindow,qApp,QAction
from PyQt5.QtGui import QIcon
import sys

class Example(QMainWindow):

    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        exitAction = QAction(QIcon('python\day09\exit3.png'),'退出',self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.triggered.connect(qApp.quit)

        # 创建工具栏
        toolBar = self.addToolBar('工具栏')
        toolBar.addAction(exitAction)

        self.setGeometry(300,300,300,200)
        self.setWindowTitle('工具栏')
        self.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())


回复

使用道具 举报

关注0

粉丝0

帖子23

发布主题
大家都在学
课堂讨论
一周热帖排行最近7x24小时热帖
关注我们
专注软件测试菁英教育

客服电话:17792550360

客服时间:9:00-21:00

卓目鸟学苑 - 专注软件测试菁英教育!( 陕ICP备2025058934号-2 )

版权所有 © 西安菁英教育科技有限公司 2023-2026