What is the appropriate way to set the WM_CLASS of an application when
using wxPython in Linux?
The WM_CLASS for every wxPython application I have tried is
("python2", "Python2"). This confuses some window managers, such as
Window Maker, by making it think every wxPython window is running from
the same application.
I'm guessing that the default value of WM_CLASS is being set based on the name of the binary executable, so that is why you are getting "python2" for wxPython applications. I don't see any way to change it in the wx API, but you can probably bypass it by calling directly to a gtk or Xlib API via ctypes. If you are able to work out the details of this please add a page to the wiki about it.
···
On 11/17/10 7:39 PM, drcouzelis wrote:
What is the appropriate way to set the WM_CLASS of an application when
using wxPython in Linux?
The WM_CLASS for every wxPython application I have tried is
("python2", "Python2"). This confuses some window managers, such as
Window Maker, by making it think every wxPython window is running from
the same application.
I'm guessing that the default value of WM_CLASS is being set based on
the name of the binary executable, so that is why you are getting
"python2" for wxPython applications. I don't see any way to change it
in the wx API, but you can probably bypass it by calling directly to a
gtk or Xlib API via ctypes. If you are able to work out the details of
this please add a page to the wiki about it.
Thanks for the response. Since there isn't a way to set it in
wxPython, I will try implementing it with ctypes.
Is there a wxPython way to check which environment I'm using? (I
should only set the WM_CLASS if the application is running on Linux /
GTK)
Could you please recommend a good place to learn about calling C
functions via ctypes? I will use it to call the
"gtk_window_set_wmclass" function in GTK.
I'm guessing that the default value of WM_CLASS is being set based on
the name of the binary executable, so that is why you are getting
"python2" for wxPython applications. I don't see any way to change it
in the wx API, but you can probably bypass it by calling directly to a
gtk or Xlib API via ctypes. If you are able to work out the details of
this please add a page to the wiki about it.
Thanks for the response. Since there isn't a way to set it in
wxPython, I will try implementing it with ctypes.
Is there a wxPython way to check which environment I'm using? (I
should only set the WM_CLASS if the application is running on Linux /
GTK)
You can look at something like system.platform, or for more details you can look at the items in the platform module. Or you can look at items in wx.PlatformInfo if all you need is to know which wx port you have.
Could you please recommend a good place to learn about calling C
functions via ctypes? I will use it to call the
"gtk_window_set_wmclass" function in GTK.
I usually just stumble around in the dark until I get something that works. There is some ctypes calls to gtk functions in wx.lib.wxcairo you can look at for an example.
I usually just stumble around in the dark until I get something that
works. There is some ctypes calls to gtk functions in
wx.lib.wxcairo you can look at for an example.
Thank you, that information has helped a lot.
After a lot of stumbling around in the dark myself, I feel like I'm
getting close. I think the last thing I need is the root GTK window to
send as a parameter to the "gtk_window_set_wmclass" function.
I see that the wxPython source code has a function called
"wxGetRootWindow" (app.cpp) which returns what I need. Is it possible
to call that from Python?
No, it is not part of the public API and so it is not wrapped in wxPython.
···
On 11/19/10 7:58 AM, drcouzelis wrote:
I usually just stumble around in the dark until I get something that
works. There is some ctypes calls to gtk functions in
wx.lib.wxcairo you can look at for an example.
Thank you, that information has helped a lot.
After a lot of stumbling around in the dark myself, I feel like I'm
getting close. I think the last thing I need is the root GTK window to
send as a parameter to the "gtk_window_set_wmclass" function.
I see that the wxPython source code has a function called
"wxGetRootWindow" (app.cpp) which returns what I need. Is it possible
to call that from Python?