In this article we want to learn about Getting Started with PySide6: Building Your First Window.
What is PySide6 ?
PySide6 is Python binding for the cross-platform graphical user interface (GUI) toolkit Qt. It is powerful tool that can be used to develop desktop applications that are compatible with multiple operating systems such as Windows, Linux, and macOS.
In this article, we will provide a brief introduction to PySide6 and demonstrate how to create basic window using PySide6.
Getting Started with PySide6
To get started with PySide6, you will need to install it on your system. You can do this by running the following command in your terminal:
1 |
pip install PySide6 |
Once you have installed PySide6, you can begin creating your first window.
Creating a Basic Window
for creating basic window in PySide6, you will need to create QApplication object and QMainWindow object. The QApplication object is responsible for managing the application’s event loop, while the QMainWindow object is the main window of the application.
This is a simple code to create your first GUI Window with PySide6:
1 2 3 4 5 6 7 8 9 |
import sys from PySide6.QtWidgets import QApplication, QMainWindow app = QApplication(sys.argv) window = QMainWindow() window.show() sys.exit(app.exec()) |
In the above code we first imported the necessary modules from PySide6. after that we have created QApplication object and QMainWindow object. The QMainWindow object is assigned to the window
variable.
Finally, we call the show()
method to display the window and the sys.exit()
method to start the application’s event loop.
Run the complete code and this will be the result.

Customizing the Window
Now that we have created basic window we can customize it according to our needs. we can add widgets such as buttons, labels, and text boxes, and also we can modify the window’s appearance by changing its size, title, and background color.
This is the code that demonstrates how to change the window’s title and size:
1 2 3 4 5 6 7 8 9 10 11 |
import sys from PySide6.QtWidgets import QApplication, QMainWindow app = QApplication(sys.argv) window = QMainWindow() window.setWindowTitle("My First PySide6 Window") window.setGeometry(100, 100, 500, 500) window.show() sys.exit(app.exec()) |
In the above code, we have added two new lines. The first line sets the window’s title to “My First PySide6 Window,” and the second line sets the window’s geometry to (100, 100, 500, 500), which specifies the window’s position on the screen (100 pixels from the left and 100 pixels from the top) and its size (500 pixels wide and 500 pixels high).
-
Learn More on Python
- Get Started with wxPython: A Complete Guide to Building GUI Applications
- Python: The Most Versatile Programming Language of the 21st Century
- Tkinter: A Beginner’s Guide to Building GUI Applications in Python
- PySide6: The Cross-Platform GUI Framework for Python
- The Ultimate Guide to Kivy: Building Cross-Platform Apps with Python
- Discover the Power of Django: The Best Web Framework for Your Next Project
- How to Earn Money with Python
- Why Flask is the Ideal Micro-Web Framework
- Python Pillow: The Ultimate Guide to Image Processing with Python
- Get Started with Pygame: A Beginner’s Guide to Game Development with Python
- Python PyOpenGL: A Guide to High-Performance 3D Graphics in Python
- The Cross-Platform Game Development Library in Python
- Unleash the Power of Computer Vision with Python OpenCV
- PyQt6 Charts: An Overview and its Importance in Data Visualization
- Maximizing Your Productivity with Python and Excel
Run the complete code and this will be the result.

Final Thoughts
In this article we have provided brief introduction to PySide6 and demonstrated how to create basic window using PySide6. We have also shown how you can customize window’s appearance and add widgets to it. with PySide6 you can create powerful and beautiful desktop applications that are compatible with multiple operating systems.