Re: Menu.Append/AppendSubMenu question

Vadim Zeitlin <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
On Wed, 5 Mar 2025 15:22:12 +1100 'raf' via wx-users wrote:

r> I've just started converting a
r> python-2.7/wxpython-2.8.12.1 app to
r> python-3.12/wxpython-4.2.2.
r> 
r> The first API change that I've run into is
r> Menu.Append().

 There has been no changes to wxMenu::Append() in C++, so I'm not sure what
the real problem is. How do you call it exactly and what is the problem
you're seeing?

r> It looks like it used to have
r> parameters: id, text, help (at least they were the ones
r> I used - there are others). And the names have changed
r> to: id, item, helpString.

 Other than the change of parameter name, this is still the same function
doing exactly the same thing as before.

r> That's fine. but when I look at:
r> 
r>   https://docs.wxpython.org/wx.Menu.html#wx.Menu.Append
r> 
r> It says:
r> 
r>   Deprecated This function is deprecated, use AppendSubMenu instead.

 Only the overload (in C++ sense) taking wxMenu submenu is deprecated.

r> But more importantly, AppendSubMenu doesn't take an id
r> parameter.

 Because submenus don't have IDs.

r> How do I pass it the Id? I also at some point saw
r> deprecation warnings for NewId().

 This function is not formally deprecated at C++ level, but it's indeed not
recommended to use it because it allocates ID from 2 disjoint ranges which
can be unexpected. wxIdManager::ReserveId() can be used instead.

 Regards,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
              https://www.tt-solutions.com/
signature.asc (application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE-----

iF0EABECAB0WIQQx+vLQdOwioQqkxtoG6kHeT2wehgUCZ8h63AAKCRAG6kHeT2we
hnj9AJ4/OFuBf1jP8IKOu/h711by9w3gXQCZAeYcCdD1pAwrENOb8FtjtPL+aNw=
=kHlN
-----END PGP SIGNATURE-----
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.