From bb1c47aace994bb20d87d81594493a4df0a73a48 Mon Sep 17 00:00:00 2001 From: Rebecca Claire Murphy Date: Tue, 24 Nov 2020 21:01:31 -0500 Subject: [PATCH] Add High DPI Support for Windows --- gui/app.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gui/app.py b/gui/app.py index ac9ec9ed22..725fb56398 100644 --- a/gui/app.py +++ b/gui/app.py @@ -36,6 +36,22 @@ def OnInit(self): # Set language stuff and update to last used language. self.UpdateLanguage(config.language) + try: + from ctypes import OleDLL + # Turn on high-DPI awareness to make sure rendering is sharp on big + # monitors with font scaling enabled. + OleDLL('shcore').SetProcessDpiAwareness(1) + except AttributeError: + # We're on a non-Windows box. + pass + except OSError: + # exc.winerror is often E_ACCESSDENIED (-2147024891/0x80070005). + # This occurs after the first run, when the parameter is reset in the + # executable's manifest and then subsequent calls raise this exception + # See last paragraph of Remarks at + # [https://msdn.microsoft.com/en-us/library/dn302122(v=vs.85).aspx](https://msdn.microsoft.com/en-us/library/dn302122(v=vs.85).aspx) + pass + return True #----------------------------------------------------------------------- @@ -74,4 +90,4 @@ def UpdateLanguage(self, lang=None): else: pyfalog.debug("Cannot find langauge: " + lang) - self.locale = wx.Locale(wx.Locale.FindLanguageInfo(LocaleSettings.defaults['locale']).Language) \ No newline at end of file + self.locale = wx.Locale(wx.Locale.FindLanguageInfo(LocaleSettings.defaults['locale']).Language)