-
Notifications
You must be signed in to change notification settings - Fork 0
/
sxwhapp.py
48 lines (36 loc) · 1014 Bytes
/
sxwhapp.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
import logging
import sys
import threading
import time
from PyQt5.QtCore import QObject, pyqtSignal, QTimer, QThread
from PyQt5.QtWidgets import QApplication
from ui.config import Config
from ui.mainwindow import MainWindow
from ui.state import State
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger()
log.propagate = False
class Timer(QObject):
enabled = True
def run(self):
while Timer.enabled:
time.sleep(1)
Timer.emit_signal()
def start(self):
threading.Thread(target=self.run).start()
@staticmethod
def emit_signal():
State.events.click_1s.emit()
@staticmethod
def stop_it():
Timer.enabled = False
if __name__ == "__main__":
# Initialize and run the PyQt application
qt_app = QApplication(sys.argv)
qt_app.aboutToQuit.connect(Timer.stop_it)
Config.load_config()
mainWindow = MainWindow()
timer = Timer()
timer.start()
mainWindow.show()
sys.exit(qt_app.exec_())