Python3+pyqt5+pycharm Desktop GUI Development

Source: Internet
Author: User
Tags qt designer

Search the Internet for a long time, find a reliable link address.

Thanks to the author, original address: http://blog.sina.com.cn/s/blog_989218ad0102wz1k.html

======================================================

First look at the effect: Figure 1
Yes, students who have learned C # should be familiar with this interface, button style and interface style is very similar, never thought, Python can make such an interface, simply. (Figure 1)
Body Start
First, install Python
Why do you say this, we open the PIP, Search: PYQT5, or directly open the following connection:
https://pypi.python.org/pypi/PyQt5/5.9.1
Figure 2
As you can see (Figure 2), the Python version supported by PYQT5 is starting from 3.5, and the blogger started with a 3.4, which has been ^~^ for 2 hours.
Find a python3.5 or above version to install:
https://www.python.org/downloads/windows/
Second, install PYQT5
It is recommended to use PIP installation:
PIP3 Install PYQT5
Wait a moment, continue to install Pyqt5-tools
Pip Install Pyqt5-tools
Third, the configuration Pycharm
Website Download Installation pycharm:https://www.jetbrains.com/pycharm/
1, click: File-"Settings
Figure 3
2, Tools-"External Tools-" click "+" (Figure 4) (PS: Below is my configuration, your software is not very normal, continue to look down)
Figure 4
3, set QT Designer modify three places, other places by default:
NAME:QT Designer programs:d:\program files\python35\lib\site-packages\pyqt5-tools\designer.exe Working directory:$ projectfiledir$
(Ps:programs parameters need to be modified to the "Designer.exe" path inside your computer) (Figure 5)
Figure 5
4, configure Pyuic set four places, other can default (I do not know how to change, then the default bar)
Name:pyuic programs:d:\program files\python35\python.exe parameters:-m PyQt5.uic.pyuic $FileName $-O $ filenamewithoutextension$.py Working directory: $ProjectFileDir $
(Ps:programs parameters need to be modified to the Python "python.exe" path inside your computer) (Figure 6)
Figure 6
Iv. use of Qt Designer

1, after completing the above steps, click Tools-"External tools-" QT Designer to start our QT Designer (Figure 7)
Figure 7
2, start after the selection: Widget, create a blank window (Figure 8), click Create, other default on the line
Figure 8
3, from the left 1 area drag, note is "drag" control to 2 area, in the 3 area to modify the corresponding attributes (Figure 9), much like vs have Wood has
Figure 9
4, last night after the basic interface settings, you will see the same directory generated a ". UI" file (Figure 10)
Figure 10
5, right key External Tools-Pyuic, convert ". UI" File to ". py" file (Figure 11)
Figure 11
6, at this time, if all is normal, no error, will be in the same directory to generate the corresponding ". py" file (Figure 12)
Figure 12
7, the following code, put the generated ". py" file, put the last line (note indent)
If __name__== "__main__": Import sys from Pyqt5.qtgui import qicon app=qtwidgets.qapplication (SYS.ARGV) wid Get=qtwidgets.qwidget () Ui=ui_form () ui.setupui (widget) Widget.setwindowicon (Qicon (' web.png ')) #增加icon图标 if no pictures Can not have this sentence widget.show () sys.exit (App.exec_ ())
8, run start, OK, congratulations, opened the Pythongui




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.