diff --git a/daemon/core/gui/app.py b/daemon/core/gui/app.py index e70b9f52..c3ab4b6b 100644 --- a/daemon/core/gui/app.py +++ b/daemon/core/gui/app.py @@ -1,5 +1,5 @@ import tkinter as tk -from tkinter import ttk +from tkinter import font, ttk from core.gui import appconfig, themes from core.gui.coreclient import CoreClient @@ -22,6 +22,8 @@ class Application(tk.Frame): # load node icons NodeUtils.setup() + self.fonts_size = {name: font.nametofont(name)["size"] for name in font.names()} + # widgets self.menubar = None self.toolbar = None diff --git a/daemon/core/gui/dialogs/preferences.py b/daemon/core/gui/dialogs/preferences.py index 9c3da76a..a10e7e89 100644 --- a/daemon/core/gui/dialogs/preferences.py +++ b/daemon/core/gui/dialogs/preferences.py @@ -5,7 +5,7 @@ from typing import TYPE_CHECKING from core.gui import appconfig from core.gui.dialogs.dialog import Dialog -from core.gui.themes import FRAME_PAD, PADX, PADY +from core.gui.themes import FRAME_PAD, PADX, PADY, scale_fonts if TYPE_CHECKING: from core.gui.app import Application @@ -119,12 +119,13 @@ class PreferencesDialog(Dialog): self.gui_scale.set(round(self.gui_scale.get(), 2)) app_scale = self.gui_scale.get() self.app.canvas.app_scale = app_scale - screen_width = self.app.master.winfo_screenwidth() - screen_height = self.app.master.winfo_screenheight() - scaled_width = WIDTH * app_scale - scaled_height = HEIGHT * app_scale - x = int(screen_width / 2 - scaled_width / 2) - y = int(screen_height / 2 - scaled_height / 2) - self.app.master.geometry(f"{int(scaled_width)}x{int(scaled_height)}+{x}+{y}") - - self.app.toolbar.scale(app_scale) + scale_fonts(self.app.fonts_size, app_scale) + # screen_width = self.app.master.winfo_screenwidth() + # screen_height = self.app.master.winfo_screenheight() + # scaled_width = WIDTH * app_scale + # scaled_height = HEIGHT * app_scale + # x = int(screen_width / 2 - scaled_width / 2) + # y = int(screen_height / 2 - scaled_height / 2) + # self.app.master.geometry(f"{int(scaled_width)}x{int(scaled_height)}+{x}+{y}") + # + # self.app.toolbar.scale(app_scale) diff --git a/daemon/core/gui/themes.py b/daemon/core/gui/themes.py index 26ee5379..482c86d2 100644 --- a/daemon/core/gui/themes.py +++ b/daemon/core/gui/themes.py @@ -1,5 +1,5 @@ import tkinter as tk -from tkinter import ttk +from tkinter import font, ttk THEME_DARK = "black" PADX = (0, 5) @@ -198,3 +198,10 @@ def theme_change(event: tk.Event): relief=tk.NONE, font=("TkDefaultFont", 8, "normal"), ) + + +def scale_fonts(fonts_size, scale): + for name in font.names(): + f = font.nametofont(name) + if name in fonts_size: + f.config(size=int(fonts_size[name] * scale))