目标:
通过Python调用PyQt5相关的库函数,生成一个简单的窗口
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 27 13:06:17 2018
@author: liuqiang
"""
from PyQt5.QtWidgets import QApplication, QWidget
class App(QWidget):
def __init__(self):
super(App, self).__init__()
self.title = 'PyQt5 simple window'
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.show()
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())
运行结果为: