When I launch a wxPython program on macOS (Apple M2), it stays in background, and come to foreground (and get wx.EVT_ACTIVATE event) only when I manually click on its icon on the Dock.
There is no such issue with the GUI programs written with Tkinter or PyQt.
I tried googling for solutions, and only got a trick of manually bring the program to foreground by calling NSApp().activateIgnoringOtherApps_(True)
through the AppKit module – but this should be a temporary workaround.
Here is the test code:
import wx
def on_act(evt):
print('EVT_ACTIVATE')
app = wx.App()
frame = wx.Frame(None, title='Hello World!')
frame.Bind(wx.EVT_ACTIVATE, on_act)
frame.Show()
app.MainLoop()
My environment is:
- CPU: Apple M2 Pro
- OS: macOS 13.4.1
- Python 3.11.4 (installed through
brew install python
) - wxPython 4.2.1