1. Creating a simple window

To create an empty window, we need two ingredients: a QApplication object and a QMainWindow object. The QApplication object manages the GUI application's control flow and main settings, while the QMainWindow object provides the framework for building an application's user interface.

simple_gui.py
1
2
3
4
5
6
7
8
from PySide6 import QtWidgets
from PySide6.QtCore import Slot


app = QtWidgets.QApplication()
window = QtWidgets.QMainWindow()
window.show()
app.exec()

The code above creates an empty window. The show() method displays the window, and the exec() method starts the application's event loop. The event loop is a loop that waits for events to happen and then dispatches them to the appropriate event handlers. Examples of events are clicking on buttons in your application or typing text into a text field. Adding the above code to the script will show an empty window:

Empty window