0
votes

I'm brand new to wxWidgets. I'm tyring to use someone elses routines that provide a GUI for a data analysis tool. I haven't been able to contact the author... but I'm getting this error on line 106:

PyAssertionError: C++ assertion "!sizer || m_containingSizer != sizer" failed at /BUILD/wxPython-src-2.9.2.4/src/common/wincmn.cpp(2275) in SetContainingSizer(): Adding a window to the same sizer twice?

The offending code looks like this:

        coord_panel = wx.Panel(pane, WID.ANY)
    grid_sizer = wx.FlexGridSizer(3,4)
    coord_panel.SetSizer(grid_sizer)
    rc_x_label =  wx.StaticText(coord_panel, WID.ANY, "x :")
    rc_y_label =  wx.StaticText(coord_panel, WID.ANY, "y :")
    rc_z_label =  wx.StaticText(coord_panel, WID.ANY, "z :")
    self.rc_x = wx.TextCtrl(coord_panel, WID.ANY, style=wx.TE_READONLY, size=(75,-1))
    self.rc_y = wx.TextCtrl(coord_panel, WID.ANY, style=wx.TE_READONLY, size=(75,-1))
    self.rc_z = wx.TextCtrl(coord_panel, WID.ANY, style=wx.TE_READONLY, size=(75,-1))
    empty_label = wx.StaticText(coord_panel, WID.ANY, "  ")
    self.edit_cam_btn = wx.Button(coord_panel, -1, "Edit", size=(50,-1))
    grid_sizer.AddMany([(rc_x_label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT),
                        (self.rc_x, 0), (empty_label, 0), (empty_label, 0),\
                        (rc_y_label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT), \
                        (self.rc_y, 0), (empty_label, 0), (self.edit_cam_btn, 0),\
                        (rc_z_label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT), \
                        (self.rc_z, 0), (empty_label, 0)])

It's generating the error on the grid_sizer.AddMany line. Anyone see the issue?

Thx!

1

1 Answers

-1
votes

The code is incorrect, you can't add the same empty_label control multiple times to the sizer. You need to create a new control (which is luckily not very difficult for an empty label) every time.

A better idea would be to avoid using empty labels completely and use spacers or just intra-row gap instead but this would require more changes to your code.