-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathframe.py
executable file
·62 lines (44 loc) · 1.32 KB
/
frame.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
51
52
53
54
55
56
57
58
59
60
61
62
#! /usr/bin/env python3
import logging.config
import sys
import yaml
from PyQt5 import QtWidgets
from gui.photo_app import PhotoFrame
from utils.config import Config
FRAME_CONFIG = "config.yml"
LOG_CONFIG = "logging.yml"
with open(LOG_CONFIG, 'rt') as f:
logging.config.dictConfig(yaml.safe_load(f.read()))
logger = logging.getLogger(__name__)
def main():
"""
Create the photo frame application
"""
sys._excepthook = sys.excepthook
sys.excepthook = exception_hook
app = QtWidgets.QApplication(sys.argv)
config = Config(FRAME_CONFIG)
try:
frame = PhotoFrame(config)
frame.splash_screen(5000)
app.processEvents()
frame.setup()
frame.start()
except KeyError as exception:
print("Error setting up frame: ", exception)
sys.exit(1)
app.exec_()
def exception_hook(exctype, value, traceback):
"""
Handle exceptions in the Qt application. Prevents exceptions being consumed silently by Qt.
:param exctype: the type of exception
:param value: the exception contents
:param traceback: the stack trace
"""
# Print the error and traceback
print(exctype, value, traceback)
# Call the normal Exception hook after
sys._excepthook(exctype, value, traceback)
sys.exit(1)
if __name__ == '__main__':
main()