-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
61 lines (40 loc) · 1.54 KB
/
main.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
#!/usr/bin/env python3
"""Entry point for the EasyMoney application."""
__copyright__ = 'Copyright © 2019, Erik Anderson, James Abernathy, and Tyler Gerritsen'
__license__ = 'MIT'
import os.path
import sys
def pythonw_disable_std_streams(
) -> None:
"""Disable output streams when running in console-less mode on Windows
(using `pythonw`) to prevent a crash when Kivy attempts to print to
unopened `stdout` and `stderr`.
"""
python_filename_without_extension = os.path.splitext(
os.path.basename(sys.executable))[0]
if python_filename_without_extension == 'pythonw':
# Interpreter hasn't opened standard pipes
sys.stdout = open(os.devnull, 'w')
sys.stderr = open(os.devnull, 'w')
# Don't waste time printing logs
os.environ['KIVY_NO_CONSOLELOG'] = '1'
if __name__ == '__main__':
# Disable streams before anything attempts to print
pythonw_disable_std_streams()
# Store Kivy configuration and logs in a local folder
os.environ['KIVY_HOME'] = os.path.join(
os.path.dirname(os.path.realpath(__file__)), '.kivy')
import kivy
kivy.require('1.9.0')
from model.sim_model import SimModel
from controller.sim_controller import SimController
from view.logging_view import LoggingView
from view.window_view import WindowView
def main() -> None:
"""Program entry point that opens the application window."""
controller = SimController(SimModel())
logger = LoggingView(controller)
window = WindowView(controller)
window.run()
if __name__ == '__main__':
main()