How to Install PYQT

INSTALLATION PROCESS FOR PYQT

PyQt is the combination of Python programming language and Qtlibrary . It is one of the python’s option for GUI. Qt is a cross platform application framework which is used to develop application software which is able to run on various software and hardware platforms.

About PyQt

PyQt is one of the most popular Python bindings for the Qt cross –platform. PyQt is developed by the British firm Riverbank Computing. PyQt supports Microsoft Windows as well as Unix, Linux and macOS. Like Qt, PyQt is also a free software. PyQt is implemented as a Python plug-in. It contain dual license available under GPL and Commercial license.
PyQt API is set modules containing around 440 classes and over 6,000 functions and methods.QtGui module holds all the graphical controls while QtCore holds no GUI functionality for working with file, directory, etc. Other then this there are modules for working with SQL(QtSql), SVG(QtSvg), XML(QtXml) and many more.The PyQt version 4 works with both python 2 and python 3. PyQt version 5 only supports python 3. Popular alternatives of PyQt are PySide, PyGTK, wxPython,Tkinter.PyQt is beneficial to the software developer who are interested to learn the graphical applications.
PyQt API is set modules containing around 440 classes and over 6,000 functions and methods

Steps to download

If you are new user and do not have PyQt installed on your PC then you need to follow the following steps
To download you need to click on the following link:
https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/

Step 1

You can download and install the appropriate installer corresponding to python version (2.7 or 3.4) and operating system (32- bit or 64- bit).

It will take a moment to download and then double click on the downloaded file.

Step 2

Installation steps:

After clicking on the downloaded file a “User Account control” box will appear. You need to click on “Yes” button for further installation.
After that again a box will pop up which will ask you to continue with installation and you need to click on “Yes” button for further process

Step 3

On clicking “Yes” button a PyQt Setup Wizard will pop up, there you need to click on “Next” button.

Step 4

On clicking “Next” button a “License Agreement” box will appear where you need to click on “I Agree” button to proceed further installation.

Step 5

On agreeing the license agreement a new box will pop up where you can choose components. And then click on “Next” button.

Step 6

Another box will appear which will provide you the option to choose install location. Here, you can change the install location by clicking on “Browse” button but it’s better to use the location as provided and clickon “Install” button

Step 7

On clicking “Install” button your setup is start installing

Step 8

After the completion of installation a “Completing the PyQt Setup Wizard” will open where you need to click on “Finish” button to finish the installation process.

Step 9

Hence the downloading and installation of PyQt setup is done successfully.

Designing in PyQt

PyQt installer carries with it a GUI builder tool known as Qt Designer. With its simple drag- drop interface it avoids the need to write code and simply built a GUI interface quickly. The facility to debug and build the application is not available in the Qt Designer as it is not an IDE (IDE such as Visual Studio).

First of all you need to open the PyQt for that in search type designer and the click on “Designer” option

Step 10

“Qt Designer” will open in that “New Form” box is automatically generated

Step 11

In Qt Designer you need to select top level window to create GUI interface for that in “New Form” box select “Main Window” from “templates\forms” and the click on “Create” button to create new form

Step 12

On clicking “Create” button the “MainWindow” will open where you will do your designing.

Step 13

You can change your window title from “MainWindow” to other desired name (here we have named it as login) by clicking anywhere on the window and then on the right corner there is “Property Editor” from where you can go to “window Title” and change the name of your window.
Now, for the designing look at the left corner “Widget Box”and drag- drop the desired tools on the canvas from the Widget Box
Here we have dragged lineEdit, label and pushButton from the Widget Box and dropped them on canvas.
To change the label and pushButton name double click on them and give them the desired name (here we have named label, label_2: USER ID, PASSWORD andpushButton, pushButton_2 : SAVE, CANCEL)
Or the alternative way to change the name of label and pushButtonbyselecting the label or pushButton whose text you want to change and then go to “Property Editor” -> text from there you can change the name.

Step 14

For the preview of your design press Ctrl+ R. After the completion of your design part save the file with .uiextension .

Here for writing the code we are using the NetBeans Editor in which you will write your python code and interface it with the ui file.
To connect the ui file with py file you have to edit the following changes as shown in below picture and remember to save the file with .py extension.
NOTE: save the .ui and .py extensions file on same folder so that while running the program on “Command Prompt”you can avoid the problem of tracing the path of folder.

Step 15

To run the py file open the “Command Prompt” and then give the path of folder where you have saved your ui and py file and then type python example.py (the name of py file)
If your operating system is 64- bit then there an error will generate as shown in below snap:

Step 16

This problem can be resolved by clicking on the following link
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4
and type in search pyqt and download the following PyQt4 4.11.4 cp27 cp27m win32.whl

binaries Step 17

Step 18

To install the following open the “Administrator Command Prompt” and give the path of the folder where you have saved the downloaded file and type “pip install ‘name ofdownloaded file’ ” as shown below.

Step 19

After the successful installation go to command prompt and mention the path of folder (where you have saved the ui and py file) with name of py file which you want to run.
As soon as you press “Enter” to run the py file, your ui file where you have done the designing will pop up.

Step 20

Hence we have successfully done the interfacing of Qt Designer and python coding using PyQt.

Leave a Reply

Your email address will not be published. Required fields are marked *