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 | |
---|---|
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: