1

I am running a Python console application (Linux console, app written in Python) where as part of the run, a Python GUI (wx) subprocess is started in many different places. Is there any way to let the wx GUI start without stealing focus from the console so that the user can continue using the console app uninterrupted? Any way to prevent this from happening, either from the Python GUI app side, from the console application which launches the GUI side, or from Linux side?

Thanks

2 Answers2

0

Linux is a particularly diverse system when it comes to graphical interfaces. Besides the dozens of GUI toolkits and frameworks, theres at least a dozen commonly used window managers - which are the part of the system that control focus.

The good news is that there's a standard: Extended Window Manager Hints.

While I won't pretent to have read all that, I think you can't unconditionally prevent the focus from changing to the new window - and there's many good reasons for that.

What you can do is simply shift the focus back to your console when you're done - if there's a reliable way to identify it, such as the PID or window name. You may want to check out wmctrl, which is a tool that can interact with any window manager that implements the EWMH standard. You can interface with it using subprocess, for example.

loopbackbee
  • 21,962
  • 10
  • 62
  • 97
0

I discovered a hack that works at least in Windows, you can try it on Linux. Before showing a new Frame, disable it.

frame.Disable()
frame.Show()
frame.Enable()
FogleBird
  • 74,300
  • 25
  • 125
  • 131