after upgrading from 4.1.1 to 4.2.1, the following code does not work anymore:
code
def createGui(self):
‘’‘setup the interface’’’
self.panel = wx.Panel(parent=self)
# setup the AUI manager
self._mgr = aui.AuiManager()
self._mgr.SetManagedWindow(self)
self.setupMenu()
############ UPPER AREA #################################
topPanel = wx.Panel(self.panel)
# a button to refresh the current log area
self.refresh_button = wx.Button(topPanel, label='Refresh')
self.refresh_button.Bind(wx.EVT_BUTTON, self.OnRefresh)
# a check box for repeating scan
self.repeat_check = wx.CheckBox(topPanel, label='Repeat')
self.repeat_check.SetValue(False)
self.repeat_check.Bind(wx.EVT_CHECKBOX, self.OnRepeatCheck)
# ip address ctrl
self.ip_addr = wx.TextCtrl(topPanel, size=(200, -1), style=wx.TE_PROCESS_ENTER)
self.ip_addr.Bind(wx.EVT_TEXT_ENTER, self.OnIpEnter)
tools_button = wx.Button(topPanel, label='Tools')
tools_button.Bind(wx.EVT_BUTTON, self.OnRightClick)
hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
hsizer1.AddMany([
((5, -1)),
(wx.StaticText(topPanel, label='IP Address'), 0, wx.CENTRE | wx.RIGHT, 10),
(self.ip_addr, 0, wx.CENTRE | wx.RIGHT, 10),
(tools_button, 0, wx.CENTRE | wx.RIGHT, 10),
((0, -1), 1, wx.EXPAND),
(self.repeat_check, 0, wx.CENTRE | wx.RIGHT, 10),
(self.refresh_button, 0, wx.CENTRE | wx.RIGHT, 10),
((10, 10), 0),
])
topPanel.SetAutoLayout(True)
topPanel.SetSizerAndFit(hsizer1)
self._mgr.AddPane(topPanel, aui.AuiPaneInfo().Name('top').Top().Layer(1).CloseButton(False).CaptionVisible(False))
# MAIN LIST AREA
self.listCtrl = GuruListCtrl(self.panel, simple=self.simple_mode, parent=self)
self.restoreColumnWidths()
self._mgr.AddPane(self.listCtrl, aui.AuiPaneInfo().Name('main').CentrePane().Layer(1).CloseButton(False).CaptionVisible(False))
############ BOTTOM AREA #################################
# the log pane
logPane = scrolled.ScrolledPanel(self.panel)
sizer = wx.BoxSizer()
logPane.SetSizer(sizer)
# add the text using a fixed width font
self.output = wx.richtext.RichTextCtrl(logPane, style=wx.richtext.RE_READONLY)
self.output.SetBackgroundColour(DETAILS_PANE_COLOUR)
self.output.SetFont(wx.Font(self.output.GetFont().GetPointSize(), wx.MODERN, wx.NORMAL, wx.NORMAL))
sizer.Add(self.output, 1, wx.EXPAND | wx.ALL, 0)
logPane.SetAutoLayout(True)
logPane.SetupScrolling()
self._mgr.AddPane(logPane, aui.AuiPaneInfo().Name('log').CaptionVisible(False).
BestSize(wx.Size(600, 200)).MinSize(wx.Size(600, 100)).
Bottom().Layer(1).CloseButton(False))
self._mgr.GetArtProvider().SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_NONE)
self._mgr.Update()
# right click menu
self.createPopupMenus()
self.listCtrl.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.listCtrl)
self.listCtrl.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnDoubleClick)
it failed at self-_mgr.Update(), with the following errors:
File “C:\Work\ecu_source\ECU_Tools_Python3\EcsTools\guru\EcuGuru.py”, line 17, in
guru_gui.guru()
File “C:\Work\ecu_source\ECU_Tools_Python3\EcsTools\guru\guru_gui.py”, line 2817, in guru
win = EcuGuru(simple=False, icon_file=GURU_ICON, title=‘ECU GURU – %s’ % APP_VERSION)
File “C:\Work\ecu_source\ECU_Tools_Python3\EcsTools\guru\guru_gui.py”, line 546, in init
self.createGui()
File “C:\Work\ecu_source\ECU_Tools_Python3\EcsTools\guru\guru_gui.py”, line 645, in createGui
self._mgr.Update()
File “C:\Users\wlin\AppData\Local\Programs\Python\Python39\lib\site-packages\wx\lib\agw\aui\framemanager.py”, line 6147, in Update
self.DoUpdate()
File “C:\Users\wlin\AppData\Local\Programs\Python\Python39\lib\site-packages\wx\lib\agw\aui\framemanager.py”, line 6323, in DoUpdate
self._frame.SetSizer(sizer)
wx._core.wxAssertionError: C++ assertion “CheckExpectedParentIs(w, m_containingWindow)” failed at …\src\common\sizer.cpp(887) in wxSizer::SetContainingWindow(): Windows managed by the sizer associated with the given window must have this window as parent, otherwise they will not be repositioned correctly.
Please use the window wxFrame@000001D771408190 (“ECU GURU – 33aaf37ad3”, HWND=0000000000240D56) with which this sizer is associated, as the parent when creating the window wxScrolledWindow@000001D7713F3A20 (“scrolledpanel”, HWND=0000000000450278) managed by it.
Error in atexit._run_exitfuncs:
wx._core.wxAssertionError: C++ assertion “GetEventHandler() == this” failed at …\src\common\wincmn.cpp(474) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed
Can someone help me to point out the issue. many thanks