scale font
This commit is contained in:
parent
8734b9f22f
commit
7fbbfa8c63
3 changed files with 22 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import font, ttk
|
||||||
|
|
||||||
from core.gui import appconfig, themes
|
from core.gui import appconfig, themes
|
||||||
from core.gui.coreclient import CoreClient
|
from core.gui.coreclient import CoreClient
|
||||||
|
@ -22,6 +22,8 @@ class Application(tk.Frame):
|
||||||
# load node icons
|
# load node icons
|
||||||
NodeUtils.setup()
|
NodeUtils.setup()
|
||||||
|
|
||||||
|
self.fonts_size = {name: font.nametofont(name)["size"] for name in font.names()}
|
||||||
|
|
||||||
# widgets
|
# widgets
|
||||||
self.menubar = None
|
self.menubar = None
|
||||||
self.toolbar = None
|
self.toolbar = None
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from core.gui import appconfig
|
from core.gui import appconfig
|
||||||
from core.gui.dialogs.dialog import Dialog
|
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:
|
if TYPE_CHECKING:
|
||||||
from core.gui.app import Application
|
from core.gui.app import Application
|
||||||
|
@ -119,12 +119,13 @@ class PreferencesDialog(Dialog):
|
||||||
self.gui_scale.set(round(self.gui_scale.get(), 2))
|
self.gui_scale.set(round(self.gui_scale.get(), 2))
|
||||||
app_scale = self.gui_scale.get()
|
app_scale = self.gui_scale.get()
|
||||||
self.app.canvas.app_scale = app_scale
|
self.app.canvas.app_scale = app_scale
|
||||||
screen_width = self.app.master.winfo_screenwidth()
|
scale_fonts(self.app.fonts_size, app_scale)
|
||||||
screen_height = self.app.master.winfo_screenheight()
|
# screen_width = self.app.master.winfo_screenwidth()
|
||||||
scaled_width = WIDTH * app_scale
|
# screen_height = self.app.master.winfo_screenheight()
|
||||||
scaled_height = HEIGHT * app_scale
|
# scaled_width = WIDTH * app_scale
|
||||||
x = int(screen_width / 2 - scaled_width / 2)
|
# scaled_height = HEIGHT * app_scale
|
||||||
y = int(screen_height / 2 - scaled_height / 2)
|
# x = int(screen_width / 2 - scaled_width / 2)
|
||||||
self.app.master.geometry(f"{int(scaled_width)}x{int(scaled_height)}+{x}+{y}")
|
# 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)
|
#
|
||||||
|
# self.app.toolbar.scale(app_scale)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import font, ttk
|
||||||
|
|
||||||
THEME_DARK = "black"
|
THEME_DARK = "black"
|
||||||
PADX = (0, 5)
|
PADX = (0, 5)
|
||||||
|
@ -198,3 +198,10 @@ def theme_change(event: tk.Event):
|
||||||
relief=tk.NONE,
|
relief=tk.NONE,
|
||||||
font=("TkDefaultFont", 8, "normal"),
|
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))
|
||||||
|
|
Loading…
Reference in a new issue