Newbie Problem with nested Notebooks

Hi
as a Newbie, working on Linux (Xubuntu) and python3, I build a GUI with nested Notebooks. In the window appears all what I expected, but in the terminal the following error messages are shown:

ulrich@ThinkPad:~/Dokumente/Tagungen/DB-2.0/wxPython$ ./Minimal.py 
(Minimal.py:5615): Gtk-CRITICAL **: 09:30:52.976: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkNotebook
(Minimal.py:5615): Gtk-CRITICAL **: 09:30:52.976: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkNotebook
(Minimal.py:5615): Gtk-CRITICAL **: 09:30:52.976: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkNotebook

Entering and straight leaving the new window brings al couple of messages like:

09:30:54: Debug: window wxPanel(0x21c9400) lost focus even though it didn't have it
09:30:54: Debug: window wxPanel(0x21c9400) lost focus even though it didn't have it

Here my minimized example of code. It makes a outer Notebook with two tabs (pages), each with a Sizer and a Label (wx.StaticText), the second with a nested Notebook, which holds one tab (page), again with a Sizer and a Label (StaticText):

import wx

class Hauptfenster(wx.Frame):
    def __init__(self):
        super().__init__(parent=None, title="Minimalbeispiel")
        # base structure
        self.pnl = wx.Panel(self)
        self.box = wx.BoxSizer(orient=wx.VERTICAL)
        self.pnl.SetSizer(self.box)
        # outer Notebook
        self.ntb = wx.Notebook(self.pnl)
        self.box.Add(self.ntb)
        # one tab (panel) added as page to the outer Notebook
        self.pnl_person = wx.Panel(self.ntb)
        self.box_person = wx.BoxSizer(orient=wx.HORIZONTAL)
        self.pnl_person.SetSizer(self.box_person)
        self.lbl_person = wx.StaticText(self.pnl_person, label="Personen-Panel (Personen bearbeiten)")
        self.box_person.Add(self.lbl_person)
        self.ntb.AddPage(self.pnl_person, "Person")
        # another tab (panel) added as page to the outer Notebook
        self.pnl_buero = wx.Panel(self.ntb)
        self.box_buero = wx.BoxSizer(orient=wx.VERTICAL)
        self.pnl_buero.SetSizer(self.box_buero)
        self.lbl_buero = wx.StaticText(self.pnl_buero, label="Büro-Panel (Für Büro-Aufgaben)")
        self.box_buero.Add(self.lbl_buero)
        self.ntb.AddPage(self.pnl_buero, "Büro")
        # nested Notebook
        self.ntb_buero = wx.Notebook(self.pnl_buero)
        self.box_buero.Add(self.ntb_buero)
        #  one tab (panel) added as page to the nested Notebook
        self.pnl_buero_farben = wx.Panel(self.ntb_buero)
        self.box_buero_farben = wx.BoxSizer(orient=wx.VERTICAL)
        self.pnl_buero_farben.SetSizer(self.box_buero_farben)
        self.lbl_buero_farben = wx.StaticText(self.pnl_buero_farben, label="Farben-Panel (zum Bearbeiten von Farben)")
        self.box_buero_farben.Add(self.lbl_buero_farben)
        self.ntb_buero.AddPage(self.pnl_buero_farben, "Farben")
        
        self.Show()

if __name__ == '__main__':
    app = wx.App()
    frame = Hauptfenster()
    app.MainLoop()

Any ideas what’s going on here? And what to do?
Thanks a lot for any help!

If you’re not seeing any unexpected behaviors or failures in your code then it’s usually safe to ignore the warnings from GTK. In this case it could be because the default initial size of the notebook(s) is not big enough. Since they will be resized by the sizers as soon as the frame is shown then there is nothing to worry about.

The lost focus log message indicates that there was a lost-focus event from GTK, but wx did not set the focus there. Again, this is something that can probably be ignored.

Thank’s a lot!

According to the size hint I found a way to prevent the GTK size warnings by fitting the notebooks size just before showing the window:

self.ntb.Fit()
self.ntb_buero.Fit()
self.Show()

It feels much better without error messages or warnings but to ignore them :joy:

The lost focus messages I will ignore. By the way: they only appear when moving the mouse over the window and immidiately leaveing it without doing anything there. That’s a not very common case :wink: The messages don’t appear when clicking into the window…

I too often see the error messages (maybe they are warning messages). Does the Posters solution work with other controls beyond just the Notebook?

I didn’t try that, sorry.