cft

Create Awesome GUI application in Python

Learn to use create a GUI applications in python using PyQt and Qt Designer.


user

HARSH MITTAL

3 years ago | 1 min read

Creating applications can be quite challenging. Each OS has its own libraries to create GUI applications and learning all of them is not a simple task. That is why it’s better to write code that can work across platforms.

Python to the rescue

Python has tons of different libraries which can help you create amazing applications which will work across platforms. Two of the majorly used libraries are PyQt and PySide. In this blog, we will explore PyQt.

Note: PyQt and PySide are very similar in terms of coding, refer to the documentation of both to read more about them.


Check out the video on youtube for code walkthrough: https://www.youtube.com/watch?v=N8BedE0UIc4

Youtube Link: https://www.youtube.com/watch?v=N8BedE0UIc4
Youtube Link: https://www.youtube.com/watch?v=N8BedE0UIc4


Github Link: https://github.com/harshmittal2210/youtubeProjects/tree/master/PyQt

Create Design

Creating design by writing code and then testing can become quite cumbersome, so for this, we will take the help of the Qt designer.

Learn more about Qt: www.qt.io

https://riverbankcomputing.com/software/pyqt/intro

Basic Application Desing
Basic Application Desing

In the above image, a basic UI is created with push buttons, progress bar, check box, text window, slider bar and some labels.

You can play around and create your own UI

Note: Keep the correct object name in Object Inspector (Left side up)

Method 1 - Import UI in python

Import UI in code directly
Import UI in code directly

With the help of the above code, you can directly call the UI file created and use it.

Method 2 - Convert UI into python code

While installing PyQt, an application is also installed called pyuic which converts UI files into python code.

You can also look for this application in the GitHub Link.

$ pyuic5.exe -x "test.ui" -o "test.py"
UI converted into python code
UI converted into python code

As you can see in the above code all the object names are the same as given in the Qt Designer.

Read the documentation carefully for better understanding. A much more detailed explanation will also e given in future blogs.


LinkedIn : www.linkedin.com/in/harshmittal2210

Github: www.github.com/harshmittal2210

Website: www.harshmittal.tech





Upvote


user
Created by

HARSH MITTAL

Currently working on developing advanced capability drones. I am interested in the field of Embedded Systems, IoT and AI.


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles