From 466a3118ce7ee91ef5ae5f298726227e81b2c953 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 17 May 2018 15:51:13 -0700 Subject: [PATCH] Merge pull request #859 from tianzhuqiao/agw_aui_4.0.x MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detach wxControl in AuiToolbar from current sizer before attach to a … (cherry picked from commit 02041bccb3d08958ab445293cda03688b32e9ed9) --- CHANGES.rst | 2 ++ wx/lib/agw/aui/auibar.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 9fe38dd8..63540851 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -134,6 +134,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)