Skip to content

Commit

Permalink
DPI awareness fix on some Windows systems 🖥
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen van Eijk committed Sep 2, 2020
1 parent 83b5c64 commit cff115f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions automagica/gui/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Copyright 2020 Oakwood Technologies BVBA"""

import json
import logging
import os
import platform
import re
Expand All @@ -11,7 +12,6 @@
from time import sleep

import keyboard

import requests
from PIL import Image, ImageTk

Expand Down Expand Up @@ -59,12 +59,16 @@ def __init__(self, *args, config=None, **kwargs):
ICONS.generate_icons()

def _windows_set_dpi_awareness(self):
import ctypes
try:
import ctypes

awareness = ctypes.c_int()
ctypes.windll.shcore.GetProcessDpiAwareness(0, ctypes.byref(awareness))
ctypes.windll.shcore.SetProcessDpiAwareness(2)
ctypes.windll.user32.SetProcessDPIAware()

awareness = ctypes.c_int()
ctypes.windll.shcore.GetProcessDpiAwareness(0, ctypes.byref(awareness))
ctypes.windll.shcore.SetProcessDpiAwareness(2)
ctypes.windll.user32.SetProcessDPIAware()
except Exception:
logging.exception("Could not set DPI awareness on Windows.")

def report_callback_exception(self, exception, value, traceback):
"""
Expand Down

0 comments on commit cff115f

Please sign in to comment.