Frame.Raise() not working on Windows

Here’s the code, which runs in a daemon thread to respond to notifications from second instances (to prevent multiple instances). All the IPC code is working fine, the only problem is that frm.Raise() doesn’t raise the window.

        if frm.IsIconized(): frm.Iconize(False)
        frm.Raise()
        frm.mToday.SetFocus()

If the window is iconized, then frm.Iconize(False) both restores the window and raises it. However, if the window is not iconized, but partially or completely hidden under another window, the taskbar icon flashes but the window is not raised.

I also tried using CallAfter(frm.Raise) but it had no effect.

What am I missing? Is the fact that this runs in a daemon thread the problem? Is this just a limitation of Windows 11?

wx.Frame inherits the Raise() method from wx.Window().

There is a caveat in the documentation which says:

Notice that this function only requests the window manager to raise this window to the top of Z-order. Depending on its configuration, the window manager may raise the window, not do it at all or indicate that a window requested to be raised in some other way, e.g. by flashing its icon if it is minimized.

Ah, I missed that. Thanks.

I have some code where I call Show before Raise. I don’t remember why I have this. Maybe you want to try it.

And: would Iconize(True); Iconize(False) work?

I’ll try those options.

But now it gets more interesting. Raise() fails to work when the app is packaged by

pyinstaller -F -w appname.py

BUT, when run from within pyCharm (after enabling “allow multiple instances”) it DOES work as expected.

Adding Show() did nothing. However the Iconize(True)/Iconize(False) trick works well. It happens so quickly that it’s not objectionable.

Unless there’s a magic incantation for getting Raise() to work, I’ll just go with that.

Thanks