Debug msg "window wxMenuBar lost focus even though it didn't have it"

Hello
Executing submenu.py (after fixing the deprecation warnings) from https://zetcode.com/wxpython/menustoolbars/ as well as my own (first) app produces this message in the shell window after a menu selection:
Debug: window wxMenuBar(0x5613eaefc450, ) lost focus even though it didn’t have it

I’m running Python 3.10.6 on Ubuntu 22.04.1 LTS and have added wxPython using sudo apt install python3-wxgtk4.0.

It’s probably not harmful, but I don’t want to have it appear when I run a demo. wx.Log.SetLogLevel( wx.LOG_Error ) suppresses it and other warnings, which helps but is rather crude. Is there a better way to make this warning go away? Am I using an outdated version?
Thanks
Wolfgang

Hi Wolfgang,

To identify the version of wxPython you have installed, run the following command:

python3 -c "import wx; print(wx.version())"

The latest version of wxPython is v4.2.0. Among the many improvements and bug fixes, the linux version also suppresses a lot of the unnecessary warning messages coming from the GTK layer. If you are not running v4.2.0, I would recommend uninstalling the version from the Ubuntu apt repository and installing the latest version using pip.

I run Linux Mint 21.1 which is based on Ubuntu 22.04. I used the following commands to install v4.2.0

URL=https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04
python3 -m pip install -U -f $URL wxPython

Ubuntu 24.04 here / 4.2.1 gtk3 (phoenix) wxWidgets 3.2.4. Wayland / Nvidia

Exact same problem.

Debug: window wxMenuBar@0x2344e60 (“menubar”) lost focus even though it didn’t have it

I will use this to address: wx.Log.SetLogLevel(wx.LOG_Error)
…but this is ugly. Is there a way to improve this by suppressing warning from a specific widget (menubar in my case)?

I found the following issue raised on the wxWidgets GitHub repository which is related to Wayland: