[wxPython] wxMDIChildFrame

Mike C. Fletcher mcfletch at rogers.com
Thu Apr 3 18:18:55 CEST 2003


Normally the best place to ask questions about wxPython is on the 
wxPython-users list.

Regarding your question (this is going to sound pedantic, 'cause I'm 
trying to show how you would solve the problem, more than the particular 
solution):

    The problem you're describing can be thought of this way:

        What is the current focus of the application/user when they are
        issuing this command via the menu?  That is, which particular
        view/window should be considered (part of) the "context" of the
        action?

    Current GUI libraries, including wxPython, embody a concept called
    "focus", which is essentially a pointer to the currently-active
    control/window (there are all sorts of problems with the "single
    focus" model when you get into multi-modal interfaces, but you
    probably don't care about that.  Single focus is the norm in WIMP
    interfaces, and wxPython is definitely a WIMP interface engine).

        * wxWindow::FindFocus()

    Note also that windows/controls are able to retrieve references to
    their parents:

        * wxWindow::GetParent()

    Then realise that you can test whether a particular window is an
    instance of your image-holding-frame just by doing a standard Python
    isinstance(...) test. 

    With that, you can walk up the sequence of parents of the
    currently-focused control looking for a window of your
    wxMDIChildFrame class.  That's then usable as (part of) the context
    of your menu action.  You can see this pattern in a number of
    places, it's dirt-common.  I've built a few of these mechanisms over
    the years, works quite nicely, however...

    Consider that this is a very common operation which is critical for
    the proper operation of MDI interfaces and wonder why people
    wouldn't have a built-in method for doing this stuff ;) :

        Then, poke around in the wxMDIParentFrame documentation for
        "GetActiveChild"

Smile so the depressed half of the world considers you a threat :) ,
Mike


Roro wrote:

>Hello everybody,
>
>I want to create a window with others windows inside : My goal is to open
>several Images and apply filters on it.
>
>In concrete terms, my main window is with a bar menu : I click on  'Open
>File' Item and select images witch I wanna see.
>And I open  Images in a window by image, and I use wxMDIParentFrame and
>wxMDIChildFrame to create my windows.
>
>
>To create Windows, I use these lines :
>
> def OnNewWindow(self, evt, ):
>        / Open Dialog window witch ask witch files to open
>        /
>        self.winCount = self.winCount + 1
>        self.win = wxMDIChildFrame(self, Self.winCount+100, "Child Window:
>%d" % self.winCount)
>        / ...
>        /
>        self.win.Show(true)
>
>The problem comes now, I want to select a window and apply a filter on it
>(filters are in my menu bar). So, I want to select image's window, click in
>the menu bar the filter and see the result in the  selected window.
>I can only apply my filter on the last opened window. the others windows
>become ghost-windows (I can see them but i can't kill them). I think, it's
>because 'win' points on the last window and run over the previous created
>window.
>I want to manage my windows, but I didn't find any solution.
>
>Is it possible to create an indirection for 'win', by passing an argument
>with the new name for the window  ?
>Can I use 'Self.winCount' to refer to my ghost-windows ? Using their ID
>number ?
>
>
>Thanks in advance for any help.
>
>
>  
>

-- 
_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/








More information about the Python-list mailing list