-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.py
46 lines (36 loc) · 1.53 KB
/
debug.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
import configparser
from PySide6.QtWidgets import QApplication, QSplashScreen
from PySide6.QtGui import QPixmap
from PySide6.QtCore import QCoreApplication, QDir, QTranslator, QLocale
from src.mainwindow import MainWindow # Import MainWindow from src
if __name__ == "__main__":
app = QApplication([])
config = configparser.ConfigParser()
try:
# Try to read the config.ini file
config.read('config.ini')
# Check if 'Settings' section and 'Language' option exist
if 'Settings' in config and 'Language' in config['Settings']:
if config['Settings']['Language'] == '1':
# Create and install the translator
translator = QTranslator()
if translator.load("translations/MUSE.zh_CN.qm"):
app.installTranslator(translator)
else:
print("Warning: The configuration file is missing the 'Settings' section or 'Language' option. Using default settings.")
except FileNotFoundError:
print("Warning: config.ini file does not exist. Using default settings.")
# Use default settings
config['Settings'] = {'Language': '0'} # default language is '0'
except Exception as e:
print(f"An error occurred: {e}")
# Show splash screen
splash_pix = QPixmap(":/png/loading.png")
splash = QSplashScreen(splash_pix)
splash.show()
# Create and show main window
window = MainWindow(config)
splash.finish(window)
window.show()
# Run the application
app.exec()