-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·68 lines (54 loc) · 2.37 KB
/
main.py
File metadata and controls
executable file
·68 lines (54 loc) · 2.37 KB
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
63
64
65
66
67
68
from PyQt5 import Qt, QtCore
from PyQt5.QtWidgets import QStyleFactory
from view.startup import StartupWidget
from model.fbs import AppInfo
from fbs_runtime.application_context import cached_property, is_frozen
from fbs_runtime.application_context.PyQt5 import ApplicationContext
from fbs_runtime.excepthook.sentry import SentryExceptionHandler
import os
import sys
import multiprocessing
class AppContext(ApplicationContext): # 1. Subclass ApplicationContext
@cached_property
def exception_handlers(self):
result = super().exception_handlers
if is_frozen():
result.append(self.sentry_exception_handler)
return result
@cached_property
def sentry_exception_handler(self):
return SentryExceptionHandler(
self.build_settings['sentry_dsn'],
self.build_settings['version'],
self.build_settings['environment'],
callback=self._on_sentry_init
)
def _on_sentry_init(self):
scope = self.sentry_exception_handler.scope
from fbs_runtime import platform
scope.set_extra('os', platform.name())
scope.set_extra('build', AppInfo().version())
def run(self): # 2. Implement run()
""" start QtApplication """
startup_window = StartupWidget()
startup_window.setWindowTitle(AppInfo().app_name() + ' Version ' + AppInfo().version())
if len(sys.argv) > 1 and type(sys.argv[1]) is str:
project_file_path = sys.argv[1]
_, ext = os.path.splitext(project_file_path)
if ext == '.sdt':
startup_window.move_to_main_window(project_file_path)
else:
startup_window.show()
# スタイルをwindows共用に(for develop)
# self.app.setStyle(QStyleFactory.create('Fusion'))
# Enable High DPI display with PyQt5
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
self.app.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
# Disable [?] button on dialogs
self.app.setAttribute(QtCore.Qt.AA_DisableWindowContextHelpButton, True)
return self.app.exec_()
if __name__ == "__main__":
multiprocessing.freeze_support()
appctxt = AppContext() # 4. Instantiate the subclass
exit_code = appctxt.run() # 5. Invoke run()
sys.exit(exit_code)