Hi everyone!
I have a wxPython application that features a taskbar with a menu.
Whenever a new frame is opened from the menu, a "task" is generated
that allows the user to activate that particular frame, like in a
normal "OS-level" taskbar.
Further details:
- Every window (except the taskbar itself) has a wx.FRAME_NO_TASKBAR
style.
- The taskbar has the concept of "current task"
My problem is that if some other application gets on top of the
wxPython one, and the user tries to reactivate it, only the taskbar
gets raised (since it's the toplevel window), and not the current task
window... I thought I could bind to EVT_ACTIVATE of the taskbar and
raise the current task window, but since Raise() focuses the window
too, I get weird behaviours when I try to use the menu.. So, is there
a way to raise a window without giving it the focus? I just need to
show on screen the current task when the user activates the taskbar.
Hi,
I must be missing something here, but, can't you just use
task_frame.Raise()
main_frame.SetFocus()
or is it something, that doesn't work in your particular frames settings?
vbr
···
2011/4/22 Joril <jorilx@gmail.com>:
Hi everyone!
I have a wxPython application that features a taskbar with a menu.
Whenever a new frame is opened from the menu, a "task" is generated
that allows the user to activate that particular frame, like in a
normal "OS-level" taskbar.
Further details:
- Every window (except the taskbar itself) has a wx.FRAME_NO_TASKBAR
style.
- The taskbar has the concept of "current task"
My problem is that if some other application gets on top of the
wxPython one, and the user tries to reactivate it, only the taskbar
gets raised (since it's the toplevel window), and not the current task
window... I thought I could bind to EVT_ACTIVATE of the taskbar and
raise the current task window, but since Raise() focuses the window
too, I get weird behaviours when I try to use the menu.. So, is there
a way to raise a window without giving it the focus? I just need to
show on screen the current task when the user activates the taskbar.
As soon as I click on the main window, the second gets raised/
focused
SetFocus is not going to have any (discernable) effect on a window that is not in the active frame, and by raising second you are deactivating main. My first thought would be to re-raise main (perhaps via wx.CallAfter) so it will then be on top of second again, but that will most likely cause an endless EVT_ACTIVATE-Raise loop so you would need to find some way to protect against that happening.
It seems like there should be a better way to do this, but I can't seem to think of it at the moment. Sorry.
>> writing a SSCCE and see if the problem is still there
So somebody has come up with an acronym for what I've been telling
people to do since the dawn of (wxPython) time... Nice!
And there's a whole site dedicated to it
SetFocus is not going to have any (discernable) effect on a window that
is not in the active frame, and by raising second you are deactivating
main. My first thought would be to re-raise main (perhaps via
wx.CallAfter) so it will then be on top of second again, but that will
most likely cause an endless EVT_ACTIVATE-Raise loop so you would need
to find some way to protect against that happening.
It seems like there should be a better way to do this, but I can't seem
to think of it at the moment. Sorry.
Well, tinkering with pygtk I found that I could obtain the effect I
was looking for, by setting and immediately removing the
_NET_WM_STATE_ABOVE hint It's _quite_ a hack but it works... Sadly
I can't trust pygtk inside a wxPython application, so I managed to do
it by writing a little C extension X-)
It uses Xlib though, so I think I'll try rewriting it using python-
xlib...
Many thanks to everyone
···
On 22 Apr, 18:28, Robin Dunn <ro...@alldunn.com> wrote: