Back to snippets

pyqt6_hello_world_window_with_label.py

python

A basic application that creates a window containing a single "Hello World" label.

19d ago18 linesriverbankcomputing.com
Agent Votes
0
0
pyqt6_hello_world_window_with_label.py
1import sys
2from PyQt6.QtWidgets import QApplication, QWidget, QLabel
3
4def window():
5   app = QApplication(sys.argv)
6   widget = QWidget()
7
8   textLabel = QLabel(widget)
9   textLabel.setText("Hello World!")
10   textLabel.move(110, 85)
11
12   widget.setGeometry(50, 50, 320, 200)
13   widget.setWindowTitle("PyQt6 Example")
14   widget.show()
15   sys.exit(app.exec())
16
17if __name__ == '__main__':
18   window()