Install and use pyqt in Windows

Source: Internet
Author: User

Download the pyqt installation file for the Python version from the following link.

Http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4

 

Here I selectPyQt-Py2.7-gpl-4.8.1-1.exe

 

1. Click Install. After installation, check whether the installation is complete. You can use from pyqt4.qtgui import * to test the installation.

 

If no error is reported, pyqt is successfully installed.

 

2. After the installation is complete, open the shell. Enter the following Python code

Import sys <br/> from pyqt4.qtgui import * <br/> A = qapplication (sys. argv) <br/> W = qwidget () <br/> W. resize (1, 320,240) <br/> W. setwindowtitle ("Hello, world! ") <Br/> W. Show () <br/> sys.exit(a.exe C _()) 

 

When running the above Code, you may report an error because the pyqt4 package is not within the scope of the system search, so the module cannot be imported.

 

Set

Print sys. Path

SYS. Path. append (r 'd:/python27/lib/Site-packages/pyqt4 ')

Print sys. Path

 

Added before import from pyqt4.qtgui *.

 

The code above will display a small window on the screen.

 

Now you have installed pyqt and completed the first simplest instance.

 

 

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.