mirror of
https://github.com/RedDeadDepresso/KKAFIO.git
synced 2025-12-22 09:20:02 +00:00
feat: new gui
This commit is contained in:
78
KKAFIO.py
78
KKAFIO.py
@@ -1,48 +1,40 @@
|
||||
import customtkinter
|
||||
import platform
|
||||
import customtkinter
|
||||
import ctypes
|
||||
# coding:utf-8
|
||||
import os
|
||||
import sys
|
||||
|
||||
from gui.frames.sidebar import Sidebar
|
||||
from gui.frames.logger import LoggerTextBox
|
||||
from gui.util.config import Config
|
||||
from gui.util.linker import Linker
|
||||
from PySide6.QtCore import Qt, QTranslator
|
||||
from PySide6.QtGui import QFont
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from qfluentwidgets import FluentTranslator
|
||||
|
||||
class App(customtkinter.CTk):
|
||||
def __init__(self):
|
||||
super().__init__("#18173C")
|
||||
self.configure_window()
|
||||
linker = Linker(self)
|
||||
config = Config(linker, "config.json")
|
||||
sidebar = Sidebar(self, linker, config, fg_color="#25224F")
|
||||
sidebar.grid(row=0, column=0, sticky="nsw")
|
||||
logger = LoggerTextBox(self, linker, config, fg_color="#262250")
|
||||
logger.grid(row=0, column=2, pady=20, sticky="nsew")
|
||||
config.load_config()
|
||||
from app.common.config import cfg
|
||||
from app.view.main_window import MainWindow
|
||||
|
||||
def configure_window(self):
|
||||
self.title("KKAFIO")
|
||||
self.geometry(f"{1500}x{850}")
|
||||
self.iconbitmap('gui/icons/karin.ico')
|
||||
"""
|
||||
solution to Settings Frame and Logger Frame widths not being
|
||||
consistent between different windows scaling factors
|
||||
"""
|
||||
self.scaling_factor = self.get_scaling_factor()
|
||||
self.grid_columnconfigure(0, weight=0)
|
||||
self.grid_columnconfigure(1, weight=0, minsize=650*self.scaling_factor)
|
||||
self.grid_columnconfigure(2, weight=1, minsize=506*self.scaling_factor)
|
||||
self.grid_rowconfigure(0, weight=1)
|
||||
|
||||
def get_scaling_factor(self):
|
||||
system = platform.system()
|
||||
|
||||
if system == 'Windows':
|
||||
user32 = ctypes.windll.user32
|
||||
return user32.GetDpiForSystem() / 96.0
|
||||
|
||||
return 1.0 # Default scaling factor for unknown or unsupported systems
|
||||
# enable dpi scale
|
||||
if cfg.get(cfg.dpiScale) != "Auto":
|
||||
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
|
||||
os.environ["QT_SCALE_FACTOR"] = str(cfg.get(cfg.dpiScale))
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = App()
|
||||
app.mainloop()
|
||||
# create application
|
||||
app = QApplication(sys.argv)
|
||||
app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)
|
||||
|
||||
# fixes issue: https://github.com/zhiyiYo/PyQt-Fluent-Widgets/issues/848
|
||||
if sys.platform == 'win32' and sys.getwindowsversion().build >= 22000:
|
||||
app.setStyle("fusion")
|
||||
|
||||
|
||||
# internationalization
|
||||
locale = cfg.get(cfg.language).value
|
||||
translator = FluentTranslator(locale)
|
||||
galleryTranslator = QTranslator()
|
||||
galleryTranslator.load(locale, "gallery", ".", ":/gallery/i18n")
|
||||
|
||||
app.installTranslator(translator)
|
||||
app.installTranslator(galleryTranslator)
|
||||
|
||||
# create main window
|
||||
w = MainWindow()
|
||||
w.show()
|
||||
app.exec()
|
||||
Reference in New Issue
Block a user