09/09/2017

My first PyQt5 application

Traditionally, when we start to learning new programming language or framework, the first application is hello world application.
I start to learn PyQt5. The first application below:


import sys
from PyQt5.QtWidgets import QApplication, QWidget,QLabel
 
class App(QWidget):
 
    def __init__(self):
        super().__init__()
        self.title = 'PyQt5'
        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) 

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = App()
    b = QLabel(ex)
    b.setText("Welcome to PyQt5!")
    b.move(50,20)
    ex.show()
    sys.exit(app.exec_())



Bài viết liên quan



Không có nhận xét nào:

Đăng nhận xét