1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

UI Scaling: Size the Scale bar as per our startup value

If we use the last configured value then the width of the Scale bar
changes as per the user's last setting, even though they might not have
yet restarted for all the rest of the UI to resize.
This commit is contained in:
Athanasius 2020-09-11 11:14:19 +01:00
parent 5f759ee2d3
commit cd24db88a9
3 changed files with 5 additions and 2 deletions

View File

@ -1068,11 +1068,13 @@ Locale LC_TIME: {locale.getlocale(locale.LC_TIME)}'''
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 = 100
config.set('ui_scale', ui_scale)
theme.default_ui_scale = root.tk.call('tk', 'scaling')
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)

View File

@ -354,8 +354,8 @@ class PreferencesDialog(tk.Toplevel):
themeframe,
variable=self.ui_scale,
orient=tk.HORIZONTAL,
length=300 * (float(config.getint('ui_scale')) / 100.0 * theme.default_ui_scale),
from_=10,
length=300 * (float(theme.startup_ui_scale) / 100.0 * theme.default_ui_scale),
from_=0,
to=400,
tickinterval=50,
resolution=10,

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.