

Now that we've practiced with a simple Hello World app, let's build a desktop app for freelance developers.

Then we'll add it to the first row and column: layout.addWidget(label, 0, 0)Īfter that, we’re going to set the window widget to the layout widget, show the window, and start the Qt event loop which'll start the app: tCentralWidget(widget) Now, let’s create the “Hello world!” label: label = QLabel() With Qt, it’s built in and much easier to do. If you were using Electron or making a web app, you would use something like Bootstrap CSS framework or CSS Flexbox to make a grid layout.

We’re using a grid layout where each widget added to the layout can be placed precisely into a particular row and column, and can span multiple rows or columns. There are other layout types that can be used, such as VBoxLayout to lay out widgets in a vertical direction, or you can use an HBoxLayout for a horizontal layout. To make a layout in Qt, you have to use a generic QWidget object because the window will display one widget at a time. Next, let's set up the application, the window, and layout for the window: app = QApplication() They are also known as components in other frameworks. Widgets are the objects that are drawn on the screen as part of the graphical user interface in Qt. We’re going to start by importing the PyQt5 widgets we'll need: # hello.pyįrom PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QGridLayout, QWidget Let’s start with a simple example that displays “Hello World”. The former documentation covers the major aspects of the PyQt interfact, while the latter is for the C++-based API of Qt. You can reference the documentation for PyQt here and if some of the documentation is lacking, you can refer to the official Qt library documentation here. You can install PyQt by installing Python and using pip with this command: pip install PyQt5 You'll need a little bit of Python coding to follow this tutorial. First, we’ll build a Hello World app before building a more useful desktop app for freelancer developers to calculate their taxes and hourly rates. It might be less popular, but I’m going to show you how effective PyQt5 can be for producing a desktop app. Qt is a graphical user interface toolkit for building desktop applications. PyQt5 is the interface that lets you use the C++-based Qt library from within Python. One popular option for developing cross-platform desktop apps is Electron and JavaScript.

There are also times when an app has to be very memory efficient and will need to have low latency (graphic intensive apps, for example). For instance, apps like Adobe After Effects or Word are still mainly used on the desktop so they can use dialog windows and keyboard shortcuts to improve the user's workflow. Web apps are very popular, but there are still times when only a desktop app can deliver a great user experience.
