-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
76 lines (57 loc) · 2.09 KB
/
app.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
67
68
69
70
71
72
73
74
75
76
from typing import *
import sys
import logging
from core.logger import get_logger
from PySide6.QtCore import (
QTranslator,
QLocale,
)
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget
from PySide6.QtGui import QIcon
# Importing the layout of the application
from layouts.app_page import AppPage
# Importing the assets for the application
import assets.assets_rc
# Defining the main window class for the application
class MainWindow(QMainWindow):
"""App's MainWindow class
Args:
QMainWindow (_type_): _description_
"""
# Initializer function for the MainWindow class
def __init__(self, parent: QWidget | None = None) -> None:
super().__init__(parent)
# Creating an instance of the AppPage class
self.app_page = AppPage()
# Setting up the UI for the app page
self.app_page.setup_ui()
# Setting the central widget for the main window
self.setCentralWidget(self.app_page.get_widget())
# Adjusting the size of the central widget
self.centralWidget().adjustSize()
# Checking if the script is being run directly
if __name__ == "__main__":
# set global logger to ignore most information
# let child logger do specific job
logging.getLogger().setLevel(logging.CRITICAL)
logger = get_logger(__name__)
logger.debug("Program Start.")
trans = QTranslator()
# Creating an instance of QApplication
app = QApplication(sys.argv)
path = "./assets/locales/"
translator = QTranslator(app)
print(QLocale.system().name())
if translator.load(path + QLocale.system().name()):
logger.debug(QLocale.system().name() + " translation loaded.")
# debug use : change to en temporarily
# translator.load(path + "en")
app.installTranslator(translator)
# Creating an instance of MainWindow
main_window = MainWindow()
# Displaying the main window
main_window.setWindowTitle("Connect-4-Kit")
main_window.setWindowIcon(QIcon("assets\icons\connect4-icon.png"))
main_window.show()
# Executing the application
app.exec()