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
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue