-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.py
executable file
·66 lines (61 loc) · 2.63 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
62
63
64
65
66
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# DotDotGoose
# Author: Peter Ersts (ersts@amnh.org)
#
# --------------------------------------------------------------------------
#
# This file is part of the DotDotGoose application.
# DotDotGoose was forked from the Neural Network Image Classifier (Nenetic).
#
# DotDotGoose is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DotDotGoose is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with with this software. If not, see <http://www.gnu.org/licenses/>.
#
# --------------------------------------------------------------------------
import os
import sys
from PyQt6 import QtWidgets, QtCore
from ddg import ExceptionHandler, MainWindow, DarkModePalette
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
if getattr(sys, 'frozen', False):
QtCore.QDir.addSearchPath('icons', os.path.join(sys._MEIPASS, 'icons'))
QtCore.QDir.addSearchPath('i18n', os.path.join(sys._MEIPASS, 'i18n'))
else:
QtCore.QDir.addSearchPath('icons', './icons/')
QtCore.QDir.addSearchPath('i18n', './i18n/')
app.setStyle('fusion')
if app.styleHints().colorScheme() == QtCore.Qt.ColorScheme.Dark:
app.setPalette(DarkModePalette())
# Palette colors are not honored by Qt6.5.3
app.setStyleSheet("QToolTip { color: #ffffff; background-color: #000000; border: 0px; padding: 2px}")
settings = QtCore.QSettings("AMNH", "DotDotGoose")
translator = QtCore.QTranslator()
if settings.value('locale'):
if translator.load(QtCore.QLocale(settings.value('locale')), "ddg", "_", "i18n:/"):
QtCore.QCoreApplication.installTranslator(translator)
else:
if translator.load(QtCore.QLocale(), "ddg", "_", "i18n:/"):
QtCore.QCoreApplication.installTranslator(translator)
main = MainWindow()
handler = ExceptionHandler()
handler.exception.connect(main.display_exception)
main.show()
screen = app.primaryScreen()
for s in app.screens():
if screen.geometry().width() < s.geometry().width():
screen = s
main.windowHandle().setScreen(screen)
main.resize(int(screen.geometry().width()), int(screen.geometry().height() * 0.85))
sys.exit(app.exec())