AUI Manager DPI Awareness

Hi all,

Searched around a lot for discussion on DPI awareness of the wx.lib.agw.aui library, and couldn’t find anything definitive, so asking here. I am running on MSW.

First - is the the AUI library fully DPI aware or not? In the simple code below I have used a ctypes API call to enable “per monitor aware V2” DPI awareness of the frame I have which contains an AUI managed panel (see SetProcessDpiAwarenessContext function (winuser.h) - Win32 apps | Microsoft Learn). This was necessary to enable any of the wx widgets to rescale properly on my high DPI displays (I have both high and normal DPI displays).

In particular for the AUI panes, the “pane resizing hint” that appears when you are resizing a pane will appear in the wrong place on any high DPI monitors in my setup, unless I make the frame DPI aware, in which case it shows in the right place. So some of the features in AUI seem to be DPI aware (at least the pane resizing hint is).

However, the sashes, the pane caption bar, and the bitmaps for the pane minimize / max / close buttons do not scale up - as you will see if you run my example code, the sashes, pane caption bar, and buttons will be very small on a high DPI display. Is there something I am missing that would make these become DPI aware? I guess I could manually resize them anytime a DPI change event occurs, but I would rather not have to do that.

I am aware that it is not recommended to set DPI awareness via a windows API call as I have below - everything I read said to do it in the manifest. So maybe that is my problem. But after hours of reading on the subject I was having trouble figuring out how to do edit a manifest, so the API call was all I could get to work. I am wanting (for the time being while I am developing my app) to be able to run it as a raw python script (so not as an .exe yet) and have DPI awareness, which seemingly would require me to edit the manifest for my python.exe, but I am not sure how to do that either. I have found threads of people specifically mentioning that editing the python.exe manifest is an acceptable way to enable DPI awareness, but could not find an explanation how to do it, so since I am ignorant of how to deal with manifests, that was a dead end for me.

import wx, ctypes
import wx.lib.agw.aui as wxAUI

class MyFrame(wx.Frame):
    def __init__(self, parent, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)  
        self.SetSize((self.FromDIP((1200,800)))) 
        rootPanel = wx.Panel(self)
        
        # Initialize AUI Manager
        self.AUIMgr = wxAUI.AuiManager(rootPanel) 

        # Create a test pane
        self.test = wx.TextCtrl(rootPanel, -1)      
        self.AUIMgr.AddPane(self.test, wxAUI.AuiPaneInfo().Left().Caption("Test").MaximizeButton(True).MinimizeButton(True).BestSize(400,800).Dockable(True).Layer(1))        
        
        # Create center pane
        text2 = wx.TextCtrl(rootPanel, -1)    
        self.AUIMgr.AddPane(text2, wxAUI.AuiPaneInfo().Name("Test2").CenterPane())
        
        self.AUIMgr.Update()
        
        self.Show()
        
def main():

    try:
        ctypes.windll.user32.SetProcessDpiAwarenessContext(ctypes.c_int64(-4))
    except:
        pass

    app = wx.App()
    mainFrame = MyFrame(None)
    app.MainLoop()    

if __name__ == '__main__':
    main() 

Maybe you can use wx.Window.GetContentScaleFactor.

See: High DPI Overview — wxPython Phoenix 4.2.1 documentation
I don’t have a high DPI monitor, so I haven’t tested it.

I can’t answer your question, but if you could use wx.aui instead of wx.lib.agw.aui does the problem occur too?