Drawing using wx.ScreenDC on macOS

Attempting to draw on the screenDC using DrawRectangle fails silently on macOS, but works on windows 10. I found a post (from 2014) that claimed this was unsupported, but the current documentation doesn’t suggest any platform specific behavior.

import wx
app = wx.App(False)
s = wx.ScreenDC()
s.DrawRectangle(60,60,500, 500)

Is this still unsupported, or is there some platform specific modification that needs to be made? On macOS I am running this with pythonw provided by anconda’s python.app package.

edit: I tried MATE and Gnome in a VM and the rectangle doesn’t render there as well.

No, it’s not supported. The more modern UI systems tend to take a greater level of control over managing the screen output and buffering, and so exclude user application access to the lower level functionality. I doubt that this trend is going to be reversed.

1 Like

I should add that there may be some platform-specific ways to accomplish something similar to wx.ScreenDC use-cases, but so far they have not been wrapped up in a way that could be used cross-platform.