Hi all,
I have a Linux-only wxPython application with a wxFrame that acts as a
menu/toolbar, it can open up new windows that are independent of the
toolbar itself.
Since the user can move any of these windows to any virtual workspace,
I'm looking for a way to move the toolbar to the current workspace
whenever the user activates a window.
I tried using Raise(), but in this way the toolbar receives the focus
too and I don't want that. Please note that I can't make the toolbar
sticky, since I don't want it on every workspace.
It probably depends on the Window Manager and how it represents windows on other desktops. IIRC some will just show/hide windows as needed when the active desktop changes, others will alter the position of windows such that they are relocated to the virtual space outside of the physical display area.
Have you tried just using tbarFrame.Show()? If Raise() is showing it on the current desktop then I would think that Show() would also. Otherwise I would try something like tbarFrame.Raise() followed by wx.CallAfter(self.Raise) where self is the window already on the virtual desktop that was just activated. Be sure to watch out for additional activation events and make sure you don't get stuck in an endless event recursion.
···
On 1/25/10 4:57 AM, Joril wrote:
Hi all,
I have a Linux-only wxPython application with a wxFrame that acts as a
menu/toolbar, it can open up new windows that are independent of the
toolbar itself.
Since the user can move any of these windows to any virtual workspace,
I'm looking for a way to move the toolbar to the current workspace
whenever the user activates a window.
I tried using Raise(), but in this way the toolbar receives the focus
too and I don't want that. Please note that I can't make the toolbar
sticky, since I don't want it on every workspace.
Have you tried just using tbarFrame.Show()? If Raise() is showing it on
the current desktop then I would think that Show() would also.
Show() does nothing
Otherwise I would try something like tbarFrame.Raise() followed by
wx.CallAfter(self.Raise) where self is the window already on the virtual
desktop that was just activated. Be sure to watch out for additional
activation events and make sure you don't get stuck in an endless event
recursion.
I tried using an instance variable to prevent that endless recursion,
like this:
def ensure_visible_toolbar(self, event):
# Called on wx.EVT_ACTIVATE
if self.raising_toolbar:
return;
self.raising_toolbar = True
self.toolbar.Raise()
wx.CallAfter(self.Raise)
event.Skip()