Re: Menu.Append/AppendSubMenu question

"'raf' via wx-users" <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
On Wed, Mar 05, 2025 at 06:26:49AM +0100, Andrea Gavana <[email protected]> wrote:

> On Wed, 5 Mar 2025 at 05.22, 'raf' via wx-users <[email protected]>
> wrote:
> 
> > Hi,
> >
> > I've just started converting a
> > python-2.7/wxpython-2.8.12.1 app to
> > python-3.12/wxpython-4.2.2.
> >
> > The first API change that I've run into is
> > Menu.Append(). It looks like it used to have
> > parameters: id, text, help (at least they were the ones
> > I used - there are others). And the names have changed
> > to: id, item, helpString.
> >
> > That's fine. but when I look at:
> >
> >   https://docs.wxpython.org/wx.Menu.html#wx.Menu.Append
> >
> > It says:
> >
> >   Deprecated This function is deprecated, use AppendSubMenu instead.
> >
> > AppendSubMenu seems like a unfortunate name for a
> > function that adds a menuitem with no submenu, but I
> > assume I can just pass it submenu=None and that'll be
> > OK (although the docs are very brief and don't state
> > whether this will be OK or not)
> >
> > But more importantly, AppendSubMenu doesn't take an id
> > parameter.
> >
> > How do I pass it the Id? I also at some point saw
> > deprecation warnings for NewId(). And looking into it,
> > it seems that I need to replace all my uses of NewId()
> > with NewIdRef(), but if I have to use AppendSubMenu(),
> > which doesn't accept an id parameter, what am I
> > supposed to do?
> >
> > I do reuse ids when the same functionality appears in
> > multiple places within the menu.
> >
> > Thanks for any advice you might have.
> >
> > cheers,
> > raf
> 
> The documentation is messed up, at least visually. As far as I know,
> Append() is deprecated only if you want to append a submenu to a menu - for
> which you should use AppendSubMenu(). For a standard wx.MenuItem it should
> work without problems and without DeprecationWarnings.
> 
> Andrea.

Thanks. That's good to hear.

It looks like I am currently using AddMenu() to add items with submenus.
That doesn't seem to exist anymore, but it also took an id parameter that
I'm using, and caching for multiple instances. Maybe it doesn't
matter. It's been many years since I had anything to do with this code,
but I might have been caching ids to prevent wasting them. It was probably
allocating new ids everytime the popup menu was dynamically generated
which would happen many times. Perhaps using AppendSubMenu with no ids
will just be better. But I'll get to that soon.

Thanks again.

cheers,
raf


-- 
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
--- 
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/wx-users/Z8kJwpHqk0cGDXUC%40raf.org.
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.