From ea53a60596946576e9ce2f2e8eca09c29ed277da Mon Sep 17 00:00:00 2001 From: Athanasius <github@miggy.org> Date: Tue, 8 Sep 2020 12:18:48 +0100 Subject: [PATCH 1/5] UI Scaling: Option added to Appearance tab of Settings --- prefs.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/prefs.py b/prefs.py index 5af25814..5a17c42a 100644 --- a/prefs.py +++ b/prefs.py @@ -337,6 +337,20 @@ class PreferencesDialog(tk.Toplevel): self.theme_label_1.grid(row=21, padx=PADX, sticky=tk.W) self.theme_button_1 = nb.ColoredButton(themeframe, text=' Hutton Orbital ', background='grey4', command=lambda:self.themecolorbrowse(1)) # Do not translate self.theme_button_1.grid(row=21, column=1, padx=PADX, pady=PADY, sticky=tk.NSEW) + + # 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) # Select UI scaling + ui_scaling = config.get('ui_scaling') + if not ui_scaling: + ui_scaling = 1.0 + self.ui_scaling = tk.StringVar(value=ui_scaling) + ui_scales = ( 0.5, 1.0, 1.5, 2.0, 3.0, 4.0) + self.uiscale_dropdown = nb.OptionMenu(themeframe, self.ui_scaling, self.ui_scaling.get(), *ui_scales) + self.uiscale_dropdown.configure(width=15) + self.uiscale_dropdown.grid(row=23, column=1, sticky=tk.W) + + # Always on top ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY*4, sticky=tk.EW) self.ontop_button = nb.Checkbutton(themeframe, text=_('Always on top'), variable=self.always_ontop, command=self.themevarchanged) self.ontop_button.grid(columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance setting @@ -632,6 +646,7 @@ class PreferencesDialog(tk.Toplevel): config.set('theme', self.theme.get()) config.set('dark_text', self.theme_colors[0]) config.set('dark_highlight', self.theme_colors[1]) + #self.tk.call('tk', 'scaling', 2.0) theme.apply(self.parent) # Notify From 1850354b8d3cdebbfe27f344b23ac6fccd658790 Mon Sep 17 00:00:00 2001 From: Athanasius <github@miggy.org> Date: Tue, 8 Sep 2020 12:27:57 +0100 Subject: [PATCH 2/5] UI Scaling: Implement a 'default' option * If no ui_scaling yet set, set it to 'default'. * 'default' added to dropdown choices. Note that you still need an application restart for this to take effect. --- EDMarketConnector.py | 6 ++++++ prefs.py | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index d79f1c8a..d08ec18d 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -1048,6 +1048,12 @@ if __name__ == "__main__": 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 = 'default' + config.set('ui_scaling', ui_scaling) + if ui_scaling != 'default': + root.tk.call('tk', 'scaling', ui_scaling) app = AppWindow(root) def messagebox_not_py3(): diff --git a/prefs.py b/prefs.py index 5a17c42a..1c6242b5 100644 --- a/prefs.py +++ b/prefs.py @@ -342,10 +342,8 @@ class PreferencesDialog(tk.Toplevel): 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) # Select UI scaling ui_scaling = config.get('ui_scaling') - if not ui_scaling: - ui_scaling = 1.0 self.ui_scaling = tk.StringVar(value=ui_scaling) - ui_scales = ( 0.5, 1.0, 1.5, 2.0, 3.0, 4.0) + ui_scales = ( 'default', 0.5, 1.0, 1.5, 2.0, 3.0, 4.0) self.uiscale_dropdown = nb.OptionMenu(themeframe, self.ui_scaling, self.ui_scaling.get(), *ui_scales) self.uiscale_dropdown.configure(width=15) self.uiscale_dropdown.grid(row=23, column=1, sticky=tk.W) @@ -642,11 +640,12 @@ 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', self.ui_scaling.get()) + #self.tk.call('tk', 'scaling', self.ui_scaling.get()) config.set('always_ontop', self.always_ontop.get()) config.set('theme', self.theme.get()) config.set('dark_text', self.theme_colors[0]) config.set('dark_highlight', self.theme_colors[1]) - #self.tk.call('tk', 'scaling', 2.0) theme.apply(self.parent) # Notify From 957d11c84b15c2dc143514b090a8a5080a398812 Mon Sep 17 00:00:00 2001 From: Athanasius <github@miggy.org> Date: Tue, 8 Sep 2020 13:16:07 +0100 Subject: [PATCH 3/5] prefs.py: Minor comment format change --- prefs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prefs.py b/prefs.py index 1c6242b5..141218e9 100644 --- a/prefs.py +++ b/prefs.py @@ -641,7 +641,7 @@ class PreferencesDialog(tk.Toplevel): Translations.install(config.get('language') or None) config.set('ui_scaling', self.ui_scaling.get()) - #self.tk.call('tk', 'scaling', self.ui_scaling.get()) + # self.tk.call('tk', 'scaling', self.ui_scaling.get()) config.set('always_ontop', self.always_ontop.get()) config.set('theme', self.theme.get()) config.set('dark_text', self.theme_colors[0]) From 94607bf55feb8e616a0ddfdfbea71f3e7c3d728b Mon Sep 17 00:00:00 2001 From: Athanasius <github@miggy.org> Date: Wed, 9 Sep 2020 13:31:36 +0100 Subject: [PATCH 4/5] UI Scaling: Use a tk.Scale instead, allowing for finer grained setting. * NB: Windows Registry has no type for 'Float', so we use a string. * We now store '0.0' to mean 'default'. --- EDMarketConnector.py | 6 +++--- prefs.py | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index d08ec18d..84ed2530 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -1050,10 +1050,10 @@ if __name__ == "__main__": root = tk.Tk(className=appname.lower()) ui_scaling = config.get('ui_scaling') if not ui_scaling: - ui_scaling = 'default' + ui_scaling = '0.0' config.set('ui_scaling', ui_scaling) - if ui_scaling != 'default': - root.tk.call('tk', 'scaling', ui_scaling) + if ui_scaling != '0.0': + root.tk.call('tk', 'scaling', float(ui_scaling)) app = AppWindow(root) def messagebox_not_py3(): diff --git a/prefs.py b/prefs.py index 141218e9..b7575721 100644 --- a/prefs.py +++ b/prefs.py @@ -341,12 +341,20 @@ 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) # Select UI scaling - ui_scaling = config.get('ui_scaling') - self.ui_scaling = tk.StringVar(value=ui_scaling) - ui_scales = ( 'default', 0.5, 1.0, 1.5, 2.0, 3.0, 4.0) - self.uiscale_dropdown = nb.OptionMenu(themeframe, self.ui_scaling, self.ui_scaling.get(), *ui_scales) - self.uiscale_dropdown.configure(width=15) - self.uiscale_dropdown.grid(row=23, column=1, sticky=tk.W) + self.ui_scaling = tk.DoubleVar() + self.ui_scaling.set(float(config.get('ui_scaling'))) + self.uiscale_bar = tk.Scale( + themeframe, + variable=self.ui_scaling, + orient=tk.HORIZONTAL, + length=300, + from_=0.0, + to=4.0, + tickinterval=0.5, + resolution=0.1, + ) + self.uiscale_bar.grid(row=23, column=1, sticky=tk.W) + self.ui_scaling_defaultis = nb.Label(themeframe, text=_('0.0 means Default')).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) @@ -640,7 +648,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', self.ui_scaling.get()) + config.set('ui_scaling', str(self.ui_scaling.get())) # self.tk.call('tk', 'scaling', self.ui_scaling.get()) config.set('always_ontop', self.always_ontop.get()) config.set('theme', self.theme.get()) From 648454026339096eca04660087f0124d9cbaf288 Mon Sep 17 00:00:00 2001 From: Athanasius <github@miggy.org> Date: Wed, 9 Sep 2020 13:35:05 +0100 Subject: [PATCH 5/5] UI Scaling: Add new strings to translation template --- L10n/en.template | 5 +++++ prefs.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/L10n/en.template b/L10n/en.template index 97e0d8b9..bc307293 100644 --- a/L10n/en.template +++ b/L10n/en.template @@ -526,3 +526,8 @@ /* Shortcut settings prompt on OSX. [prefs.py] */ "{APP} needs permission to use shortcuts" = "{APP} needs permission to use shortcuts"; +/* Label for 'UI Scaling' option [prefs.py] */ +"UI Scaling" = "UI Scaling"; + +/* Text describing that value '0.0' means 'default' [prefs.py] */ +"0.0 means Default" = "0.0 means Default"; diff --git a/prefs.py b/prefs.py index b7575721..0e64f377 100644 --- a/prefs.py +++ b/prefs.py @@ -340,7 +340,7 @@ 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) # Select UI scaling + 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'))) self.uiscale_bar = tk.Scale(