diff --git a/CHANGES.rst b/CHANGES.rst index 2d78af8c..f94bd687 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -101,6 +101,8 @@ Changes in this release include the following: +* Detach wxControl in AuiToolbar from current sizer before attach to a new one. + (#843) 4.0.1 "Lemonade" ---------------- diff --git a/wx/lib/agw/aui/auibar.py b/wx/lib/agw/aui/auibar.py index d199d77c..af61dc72 100644 --- a/wx/lib/agw/aui/auibar.py +++ b/wx/lib/agw/aui/auibar.py @@ -3072,6 +3072,9 @@ class AuiToolBar(wx.Control): sizer_item = sizer.Add((item.spacer_pixels, 1)) elif kind == ITEM_CONTROL: + if item.window and item.window.GetContainingSizer(): + # Make sure that there is only one sizer to this control + item.window.GetContainingSizer().Detach(item.window); vert_sizer = wx.BoxSizer(wx.VERTICAL) vert_sizer.AddStretchSpacer(1)