-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·51 lines (40 loc) · 1.07 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
#!/usr/bin/python3
import sys
from PyQt5.QtCore import QTranslator, QLocale
from PyQt5.QtWidgets import *
import Business
from Data.Document import Document
from GUI.MainWindow import MainWindow
import os
from pathlib import Path
__author__ = 'mamj'
def except_hook(cls, exception, traceback):
sys.__excepthook__(cls, exception, traceback)
def load_language(a):
locale = QLocale()
translator = QTranslator(a)
fname = "translate/%s.qm" % locale.name()
if not os.path.isfile(fname):
if "_" in locale.name():
index = locale.name().index('_')
fname = "translate/%s.qm" % locale.name()[:index]
if os.path.isfile(fname):
if translator.load(fname):
a.installTranslator(translator)
def main():
a = QApplication(sys.argv)
a.setQuitOnLastWindowClosed(True)
load_language(a)
if len(sys.argv) > 1:
my_file = Path(sys.argv[1])
if my_file.is_file():
document = Business.load_document(sys.argv[1])
else:
document = Document()
else:
document = Document()
main_window = MainWindow(document)
main_window.show()
sys.exit(a.exec())
sys.excepthook = except_hook
main()