Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add High DPI Support for Windows #2292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

#-----------------------------------------------------------------------
Expand Down Expand Up @@ -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)
self.locale = wx.Locale(wx.Locale.FindLanguageInfo(LocaleSettings.defaults['locale']).Language)