Popping windows to the front

444 views
Skip to first unread message

William D. Colburn (Schlake)

unread,
May 13, 2011, 11:27:33 PM5/13/11
to wxpytho...@googlegroups.com
I can't figure out how wx python can pop windows to the front. My
basic problem is that I have three windows. If the user clicks on any
of them, I want all three to pop to the front of all the windows (and
uniconify if they are) and focus to go to a specific one (even if not
the one clicked on). I'm sure wx can do it, but I can't find it
anywhere.

--
-- Schlake

C M

unread,
May 13, 2011, 11:39:05 PM5/13/11
to wxpytho...@googlegroups.com

How about, after catching an EVT_ACTIVATE event in a handler on any
frame, then using window.Raise() and window.SetFocus(), in a loop
through a list of the extant frames? Something like that. (.SetFocus
might only really work on an object that can accept focus...not
totally sure about that).

Where can you find these methods?:

http://docs.wxwidgets.org/stable/wx_wxwindow.html
(this is the wxWidgets docs, but I prefer this formatting)

Che

William D. Colburn (Schlake)

unread,
May 13, 2011, 11:55:33 PM5/13/11
to wxpytho...@googlegroups.com
> How about, after catching an EVT_ACTIVATE event in a handler on any
> frame, then using window.Raise() and window.SetFocus(), in a loop
> through a list of the extant frames? Something like that.  (.SetFocus
> might only really work on an object that can accept focus...not
> totally sure about that).

Well, I got some spectacular crashes!

I can't Focus() a frame, so that doesn't work. And moving one of the
windows causes infinite recursion. But moving the other windows is
fine.

So, I wrapped it in a test to see if it is already inside the callback
I made, and that fixes it. Raise()ing the window that is supposed to
have focus last causes it to have focus just like I want. But an
iconified window isn't popped up. What does wx call it's pop up
method? All I can find is to pop up a menu item.

-- Schlake

C M

unread,
May 14, 2011, 1:39:19 AM5/14/11
to wxpytho...@googlegroups.com
> have focus last causes it to have focus just like I want.  But an
> iconified window isn't popped up.  What does wx call it's pop up
> method?  All I can find is to pop up a menu item.

frame.Iconize(False)

See:
http://docs.wxwidgets.org/2.8/wx_wxtoplevelwindow.html#wxtoplevelwindowiconize

One way to find this is is you Google "wxFrame" and see there is no
method related to icons or such...so you try a higher level by looking
at the top part of the doc where it says, "Derived from" and then
you'd choose the first in that list--in this case, wxTopLevelWindow.
Then you may find the method you need.

Che

Gadget/Steve

unread,
May 14, 2011, 2:46:43 AM5/14/11
to wxpytho...@googlegroups.com
The other trick I find very useful goes like this:
Open a command prompt,
type:
python
import wx
frame=wx.Frame
d=dir(frame)
for i in d:
   if i.lower().find('icon') > -1:
      print i

this this gives me:
GetIcon Icon Iconize IsIconized SetIcon SetIcons

then if I type:
help(frame.Iconize)
I get:
Help on method Iconize in module wx._windows:

Iconize(*args, **kwargs) unbound wx._windows.Frame method
    Iconize(self, bool iconize=True)

Which is at least a starting point for looking at the documentation.
In general this strategy will give you at least some information about just about anything in python.

Gadget/Steve





Reply all
Reply to author
Forward
0 new messages