2018-02-27:创建一个带状态栏提示的主窗口
2018-02-27 本文已影响0人
ShapeYourself
目标:
通过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