mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 07:47:14 +03:00
UI Scaling: Switch to using integers to avoid tk bug
Using a Tk.DoubleVar() with a locale where a comma is used as the decimals separator leads to internal tk code recording values with the comma but then other tk code not accepting that back, so it always thinks the value is zero and the scale slider can't be moved. Ref: https://stackoverflow.com/questions/45289237/tkinter-scale-slider-with-float-values-doesnt-work-with-locale-of-language-that * Change to storing as a REG_DWORD under 'ui_scale' not 'ui_scaling'. * Change all the code, except the call to *set* the tk scaling to use an integer, with 100 = 100%, i.e. equivalent to the old 1.0. * Update strings slightly, so translations will need updating too. NB: The theme.default_ui_scale value for plugin authors to query is still the float that tk returns.
This commit is contained in:
parent
174e169469
commit
f2ab8f0fd1
@ -1038,7 +1038,7 @@ argv[0]: {sys.argv[0]}
|
||||
exec_prefix: {sys.exec_prefix}
|
||||
executable: {sys.executable}
|
||||
sys.path: {sys.path}'''
|
||||
)
|
||||
)
|
||||
|
||||
# TODO: unittests in place of these
|
||||
# logger.debug('Test from __main__')
|
||||
@ -1056,13 +1056,13 @@ sys.path: {sys.path}'''
|
||||
Translations.install(config.get('language') or None) # Can generate errors so wait til log set up
|
||||
|
||||
root = tk.Tk(className=appname.lower())
|
||||
ui_scaling = config.get('ui_scaling')
|
||||
if not ui_scaling:
|
||||
ui_scaling = '0.0'
|
||||
config.set('ui_scaling', ui_scaling)
|
||||
ui_scale = config.getint('ui_scale')
|
||||
if not ui_scale:
|
||||
ui_scale = 0
|
||||
config.set('ui_scale', ui_scale)
|
||||
theme.default_ui_scale = root.tk.call('tk', 'scaling')
|
||||
if ui_scaling != '0.0':
|
||||
root.tk.call('tk', 'scaling', float(ui_scaling))
|
||||
if ui_scale != 0:
|
||||
root.tk.call('tk', 'scaling', float(ui_scale) / 100.0)
|
||||
app = AppWindow(root)
|
||||
|
||||
def messagebox_not_py3():
|
||||
|
@ -527,10 +527,10 @@
|
||||
"{APP} needs permission to use shortcuts" = "{APP} needs permission to use shortcuts";
|
||||
|
||||
/* Label for 'UI Scaling' option [prefs.py] */
|
||||
"UI Scaling" = "UI Scaling";
|
||||
"UI Scale Percentage" = "UI Scale Percentage";
|
||||
|
||||
/* Text describing that value '0.0' means 'default', and changes require a restart [prefs.py] */
|
||||
"0.0 means Default{CR}Restart Required for{CR}changes to take effect!" = "0.0 means Default{CR}Restart Required for{CR}changes to take effect!";
|
||||
/* 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!";
|
||||
|
||||
/* Label for user configured level of logging [prefs.py] */
|
||||
"Log Level" = "Log Level";
|
||||
|
25
prefs.py
25
prefs.py
@ -340,22 +340,24 @@ class PreferencesDialog(tk.Toplevel):
|
||||
|
||||
# UI Scaling
|
||||
ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=4, padx=PADX, pady=PADY*4, sticky=tk.EW)
|
||||
nb.Label(themeframe, text=_('UI Scaling')).grid(row = 23, padx=PADX, pady=2*PADY, sticky=tk.W)
|
||||
self.ui_scaling = tk.DoubleVar()
|
||||
self.ui_scaling.set(float(config.get('ui_scaling')))
|
||||
nb.Label(themeframe, text=_('UI Scale Percentage')).grid(row=23, padx=PADX, pady=2*PADY, sticky=tk.W)
|
||||
self.ui_scale = tk.IntVar()
|
||||
self.ui_scale.set(config.getint('ui_scale'))
|
||||
self.uiscale_bar = tk.Scale(
|
||||
themeframe,
|
||||
variable=self.ui_scaling,
|
||||
variable=self.ui_scale,
|
||||
orient=tk.HORIZONTAL,
|
||||
length=300,
|
||||
from_=0.0,
|
||||
to=4.0,
|
||||
tickinterval=0.5,
|
||||
resolution=0.1,
|
||||
from_=0,
|
||||
to=400,
|
||||
tickinterval=50,
|
||||
resolution=10,
|
||||
)
|
||||
self.uiscale_bar.grid(row=23, column=1, sticky=tk.W)
|
||||
#self.ui_scaling_defaultis = nb.Label(themeframe, text=_('0.0 means Default') + '\n' + _('Restart Required for') + '\n' + _('changes to take effect!')).grid(row=23, column=3, padx=PADX, pady=2*PADY, sticky=tk.E)
|
||||
self.ui_scaling_defaultis = nb.Label(themeframe, text=_('0.0 means Default{CR}Restart Required for{CR}changes to take effect!')).grid(row=23, column=3, padx=PADX, pady=2*PADY, sticky=tk.E)
|
||||
self.ui_scaling_defaultis = nb.Label(
|
||||
themeframe,
|
||||
text=_('0 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
|
||||
ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY*4, sticky=tk.EW)
|
||||
@ -649,8 +651,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
config.set('language', lang_codes.get(self.lang.get()) or '')
|
||||
Translations.install(config.get('language') or None)
|
||||
|
||||
config.set('ui_scaling', str(self.ui_scaling.get()))
|
||||
# self.tk.call('tk', 'scaling', self.ui_scaling.get())
|
||||
config.set('ui_scale', self.ui_scale.get())
|
||||
config.set('always_ontop', self.always_ontop.get())
|
||||
config.set('theme', self.theme.get())
|
||||
config.set('dark_text', self.theme_colors[0])
|
||||
|
Loading…
x
Reference in New Issue
Block a user