1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-16 09:10:35 +03:00

Merge pull request #695 from EDCD/enhancement/515-ui-scaling

Scale versus the startup default value.
This commit is contained in:
Athanasius 2020-09-11 14:16:18 +01:00 committed by GitHub
commit 5effee0d67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 7 deletions

View File

@ -1062,13 +1062,20 @@ Locale LC_TIME: {locale.getlocale(locale.LC_TIME)}'''
Translations.install(config.get('language') or None) # Can generate errors so wait til log set up
root = tk.Tk(className=appname.lower())
# UI Scaling
"""
We scale the UI relative to what we find tk-scaling is on startup.
"""
ui_scale = config.getint('ui_scale')
# NB: This *also* catches a literal 0 value to re-set to the default 100
if not ui_scale:
ui_scale = 0
ui_scale = 100
config.set('ui_scale', ui_scale)
theme.default_ui_scale = root.tk.call('tk', 'scaling')
if ui_scale != 0:
root.tk.call('tk', 'scaling', float(ui_scale) / 100.0)
logger.debug(f'Default tk scaling = {theme.default_ui_scale}')
theme.startup_ui_scale = ui_scale
root.tk.call('tk', 'scaling', theme.default_ui_scale * float(ui_scale) / 100.0)
app = AppWindow(root)
def messagebox_not_py3():

View File

@ -529,8 +529,8 @@
/* Label for 'UI Scaling' option [prefs.py] */
"UI Scale Percentage" = "UI Scale Percentage";
/* Text describing that value '0' means 'default', and changes require a restart [prefs.py] */
"0 means Default{CR}Restart Required for{CR}changes to take effect!" = "0 means Default{CR}Restart Required for{CR}changes to take effect!";
/* Text describing that value '100' means 'default', and changes require a restart [prefs.py] */
"100 means Default{CR}Restart Required for{CR}changes to take effect!" = "100 means Default{CR}Restart Required for{CR}changes to take effect!";
/* Label for user configured level of logging [prefs.py] */
"Log Level" = "Log Level";

View File

@ -339,6 +339,13 @@ class PreferencesDialog(tk.Toplevel):
self.theme_button_1.grid(row=21, column=1, padx=PADX, pady=PADY, sticky=tk.NSEW)
# UI Scaling
"""
The provided UI Scale setting is a percentage value relative to the
tk-scaling setting on startup.
So, if at startup we find tk-scaling is 1.33 and have a user setting
of 200 we'll end up setting 2.66 as the tk-scaling value.
"""
ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=4, padx=PADX, pady=PADY*4, sticky=tk.EW)
nb.Label(themeframe, text=_('UI Scale Percentage')).grid(row=23, padx=PADX, pady=2*PADY, sticky=tk.W)
self.ui_scale = tk.IntVar()
@ -347,7 +354,7 @@ class PreferencesDialog(tk.Toplevel):
themeframe,
variable=self.ui_scale,
orient=tk.HORIZONTAL,
length=300,
length=300 * (float(theme.startup_ui_scale) / 100.0 * theme.default_ui_scale),
from_=0,
to=400,
tickinterval=50,
@ -356,7 +363,7 @@ class PreferencesDialog(tk.Toplevel):
self.uiscale_bar.grid(row=23, column=1, sticky=tk.W)
self.ui_scaling_defaultis = nb.Label(
themeframe,
text=_('0 means Default{CR}Restart Required for{CR}changes to take effect!')
text=_('100 means Default{CR}Restart Required for{CR}changes to take effect!')
).grid(row=23, column=3, padx=PADX, pady=2*PADY, sticky=tk.E)
# Always on top

View File

@ -116,6 +116,7 @@ class _Theme(object):
self.defaults = {}
self.current = {}
self.default_ui_scale = None # None == not yet known
self.startup_ui_scale = None
def register(self, widget):
# Note widget and children for later application of a theme. Note if the widget has explicit fg or bg attributes.