Python GUI programming (based on PYQT5)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.