In recent days on the internet to see that PyQt5 to be relatively tkinter useful, so decided to change the direction of learning PyQt5
This tutorial is based on the PYQT5 Chinese course on Gitbook, which is a study note.
Section I.
For PYQT5 to create a window, the following steps are required:
0. Import the module
1. Create an App Object
2. Create a constructor
3. Setting the Window
4. Safe Exit window
Here is the Code demo:
#!/usr/bin/env python3.6#-*-coding:utf-8-*-#导入模from pyqt5.qtwidgets import qapplication,qwidgetimport sys# Create an App Object app = Qapplication (sys.argv) #创建一个构造器w = Qwidget () #设置窗口的大小, the first number is wide, the next is the high W.resize (300,250) #将窗口移动到指定位置, the coordinates are in parentheses, The coordinate origin is the upper-left corner of the screen W.move (450,450) #设置窗口的标题w. Setwindowtitle (' SMS Bomber 0.0.1 ') #显示窗口w. Show () #安全退出sys. Exit (App.exec_ ())
The comments in the above code are already written very clearly, do not repeat it.
Thank you for reading.
Next, you'll learn how to add a window icon to a window.
Python GUI programming (based on PYQT5)