8000 Add the "Hello World!" application · realpython/materials@ee03d04 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee03d04

Browse files
committed
Add the "Hello World!" application
1 parent dc3d31d commit ee03d04

File tree

1 file changed

+27
-0
lines changed
  • pyqt-calculator-tutorial/examples

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# filename: hello.py
2+
3+
"""Simple Hello World example with PyQt5."""
4+
5+
import sys
6+
7+
# 1. Import `QApplication`, and all the required widgets
8+
from PyQt5.QtWidgets import QApplication
9+
from PyQt5.QtWidgets import QWidget
10+
from PyQt5.QtWidgets import QLabel
11+
12+
# 2. Create an instance of QApplication
13+
app = QApplication(sys.argv)
14+
15+
# 3. Create an instance of your application's GUI
16+
window = QWidget()
17+
window.setWindowTitle('PyQt5 App')
18+
window.setGeometry(100, 100, 280, 80)
19+
window.move(60, 15)
20+
helloMsg = QLabel('<h1>Hello World!</h1>', parent=window)
21+
helloMsg.move(60, 15)
22+
23+
# 4.Show your application's GUI
24+
window.show()
25+
26+
# 5. Run your application's event loop (or main loop)
27+
sys.exit(app.exec_())

0 commit comments

Comments
 (0)
0