Re: wxWindow.FindWindowById behavior change

Robin Dunn <[email protected]>
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
Alexis Collange wrote:
> Hi,
>
> It seems that the wxWindow.FindWindowById method behavior has changed.
> According to the documentation of "Classic" :
>
> /FindWindowById(self, winid)
> /
> /    Find a child of *_this window_* by window ID/
>
>
> In Phoenix FindWindowById is a static method and the search is
> recursive starting from top level window if the 'parent' parameter is
> not given.
> This new logic is unexpected for me, and I already see an issue into
> XRC module with the XRCCTRL function.
>
> /def XRCCTRL(window, str_id, *ignoreargs):/
> /    """/
> /    Returns the child window associated with the string ID in an XML
> resource./
> /    """/
> /    return window.FindWindowById(XRCID(str_id))/
>
> The ID search should be relative to the given 'window', so according
> to the new FindWindowById behavior, the return should be :
>
> /    return window.FindWindowById(XRCID(str_id), //window//)/
> /
> /
> Why this change? Search relative to the window instance seems more
> logic...
>

As described in the overloads section of the Migration Guide, this is a
case of removing the old renames that were done only because of C++
method overloading, which are not needed any longer. (IOW, one of the
"dehackifications" done for Phoenix.)

We now have the following. These two recursively search self and its
children:

    (non-static) wx.Window.FindWindow(self, id)
    (non-static) wx.Window.FindWindow(self, name)

These search either all windows in the application, or the tree rooted
at parent:

    (static) wx.Window.FindWindowById(id, parent=None)
    (static) wx.Window.FindWindowByLabel(label, parent=None)
    (static) wx.Window.FindWindowByName(name, parent=None)

Due to the renaming of overloads in Classic, and also some additions
made later in wxWidgets that conflicted with those renames, the
following module-level functions were added, and have been carried over
to Phoenix for compatibility:

    wx.FindWindowById(id, parent=None)
    wx.FindWindowByLabel(label, parent=None)
    wx.FindWindowByName(name, parent=None)

I'll fix XRCCTRL and a few other instances that I see.

Thanks for reporting this.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.