Search code examples
pythonwxpythonretina-display

how to detect Mac retina display in python?


I read that wx python 2.9.5+ supports wx.Window.GetContentScaleFactor (see http://wxpython.org/Phoenix/docs/html/Window.html#Window.GetContentScaleFactor), and will return 2.0 for a retina display.

I have a class that inherits from wx.Frame, which inherits from wx.Window. But GetContentScaleFactor is not there. Apparently there was a bug like this in wxPerl (https://rt.cpan.org/Public/Bug/Display.html?id=96136) -- something similar in wxPython?

Any ideas?

Edit: more info:

>>> wx.version()
'3.0.0.0 osx-cocoa (classic)'
>>> isinstance(wx.Frame(None), wx.Window)
True
>>> 'GetContentScaleFactor' in dir(wx.Frame(None))
False

Solution

  • It is in wxPython Phoenix: 3.0.2.dev77483 wx.Window.GetContentScaleFactor

    As Phoenix does some of the wrapping work automagically I would guess that Robin didn't get around to do this for Classic.

    Maybe do a ticket on http://trac.wxwidgets.org/ or post to wxPython-dev.