美文网首页
2018-02-27:创建一个带状态栏提示的主窗口

2018-02-27:创建一个带状态栏提示的主窗口

作者: ShapeYourself | 来源:发表于2018-02-27 13:32 被阅读0次

    目标:
    通过Python调用PyQt5的相关库函数,创建带状态栏的主窗口


    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    """
    Created on Tue Feb 27 13:24:08 2018
    
    @author: liuqiang
    """
    
    from PyQt5.QtWidgets import QApplication, QMainWindow
     
    class App(QMainWindow):
     
        def __init__(self):
            super(App, self).__init__()
            self.title = 'PyQt5 status bar example'
            self.left = 10
            self.top = 10
            self.width = 640
            self.height = 480
            self.initUI()
     
        def initUI(self):
            self.setWindowTitle(self.title)
            self.setGeometry(self.left, self.top, self.width, self.height)
            self.statusBar().showMessage('Message in statusbar.')
            self.show()
     
    if __name__ == '__main__':
        import sys
        app = QApplication(sys.argv)
        ex = App()
        sys.exit(app.exec_())
    

    运行结果为:


    Screenshot from 2018-02-27 13-29-56.png

    相关文章

      网友评论

          本文标题:2018-02-27:创建一个带状态栏提示的主窗口

          本文链接:https://www.haomeiwen.com/subject/exopxftx.html