adjust node text and edge text to scale not as fast as other components

This commit is contained in:
Huy Pham 2020-03-02 10:18:37 -08:00
parent b0a3c85f0e
commit 933f409498
2 changed files with 8 additions and 6 deletions

View file

@ -1,3 +1,4 @@
import math
import tkinter as tk import tkinter as tk
from tkinter import font, ttk from tkinter import font, ttk
@ -47,11 +48,10 @@ class Application(tk.Frame):
def setup_scaling(self): def setup_scaling(self):
self.fonts_size = {name: font.nametofont(name)["size"] for name in font.names()} self.fonts_size = {name: font.nametofont(name)["size"] for name in font.names()}
text_scale = self.app_scale if self.app_scale < 1 else math.sqrt(self.app_scale)
themes.scale_fonts(self.fonts_size, self.app_scale) themes.scale_fonts(self.fonts_size, self.app_scale)
self.icon_text_font = font.Font( self.icon_text_font = font.Font(family="TkIconFont", size=int(12 * text_scale))
family="TkIconFont", size=int(12 * self.app_scale) self.edge_font = font.Font(family="TkDefaultFont", size=int(8 * text_scale))
)
self.edge_font = font.Font(family="TkDefaultFont", size=int(8 * self.app_scale))
def setup_theme(self): def setup_theme(self):
themes.load(self.style) themes.load(self.style)

View file

@ -1,4 +1,5 @@
import logging import logging
import math
import tkinter as tk import tkinter as tk
from tkinter import ttk from tkinter import ttk
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
@ -127,8 +128,9 @@ class PreferencesDialog(Dialog):
# scale fonts # scale fonts
scale_fonts(self.app.fonts_size, app_scale) scale_fonts(self.app.fonts_size, app_scale)
self.app.icon_text_font.config(size=int(12 * app_scale)) text_scale = app_scale if app_scale < 1 else math.sqrt(app_scale)
self.app.edge_font.config(size=int(8 * app_scale)) self.app.icon_text_font.config(size=int(12 * text_scale))
self.app.edge_font.config(size=int(8 * text_scale))
# scale application window # scale application window
self.app.center() self.app.center()