From 69ec9e4d74ccd40f50cabb0a6893f5253badc6ab Mon Sep 17 00:00:00 2001 From: Tianzhu Qiao Date: Wed, 16 May 2018 22:24:41 -0700 Subject: [PATCH] Detach wxControl in AuiToolbar from current sizer before attach to a new one. --- CHANGES.rst | 2 ++ wx/lib/agw/aui/auibar.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 848ddcb4..5f2bde94 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -97,6 +97,8 @@ Changes in this release include the following: * Use BufferedDC in Repaint() to mitigate flicker (wx.lib.agw.aui). (#686) +* 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)