datetime:2019/5/16 16:13
author:nzb
创建窗口
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QDesktopWidget
from PyQt5 import QtGui
class UI_demo(QMainWindow):
"""用户界面"""
def __init__(self):
super().__init__()
self.title = 'PyQt5 demo'
self.left = 600
self.top = 200
self.width = 800
self.height = 600
self.initWindow()
def initWindow(self):
self.setWindowIcon(QtGui.QIcon('../img/home.ico'))
self.setWindowTitle(self.title)
self.resize(800, 600)
self.center()
self.show()
def center(self):
"""窗口居中"""
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
if __name__ == "__main__":
app = QApplication(sys.argv)
ex = UI_demo()
sys.exit(app.exec_())