-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarter.py
executable file
·50 lines (36 loc) · 1.16 KB
/
starter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
# Basic starter Qt class
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
import time
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.setWindowTitle("My Awesome App")
self.setGeometry(350, 100, 1280, 720) #posX, posY, w, h
# Layout
layout = QVBoxLayout()
self.label = QLabel("Center")
self.label.setAlignment(Qt.AlignCenter)
button = QPushButton("Button!")
button.pressed.connect(self.button_press)
layout.addWidget(self.label)
layout.addWidget(button)
# Widget
w = QWidget()
w.setLayout(layout)
self.setCentralWidget(w)
# Show the Qt app
self.show()
# self.timer = QTimer()
# self.timer.setInterval(1000)
# self.timer.timeout.connect(self.recurring_timer)
# self.timer.start()
def button_press(self):
# Pass in the function
print('this is a button press')
app = QApplication([]) # Holds the event loop
window = MainWindow()
app.exec_()