wxPython;右键单击任何文本字段中的上下文菜单都可能导致程序崩溃,并出现错误;m_menuDepth>;0";?

wxPython;右键单击任何文本字段中的上下文菜单都可能导致程序崩溃,并出现错误;m_menuDepth>;0";?,python,python-3.x,windows-10,wxpython,Python,Python 3.x,Windows 10,Wxpython,我注意到,当右键单击wxPython小部件中的文本字段时,如果用户选择插入Unicode控制字符选项并插入其中任何字符,程序将抛出此错误 如果不从头开始重做上下文菜单,不完全禁用上下文菜单,也不在try except中包装大量内容(捕捉wx.\u core.wxAssertionError是一个非常坏的习惯,因为它们通常是致命的),如何防止此错误 编辑: 该错误可在以下位置复制: 操作系统:Win 10 Enterprise 2016 LTSB/Win 10 Pro(在两个平台上都进行了测试)

我注意到,当右键单击wxPython小部件中的文本字段时,如果用户选择
插入Unicode控制字符
选项并插入其中任何字符,程序将抛出此错误

如果不从头开始重做上下文菜单,不完全禁用上下文菜单,也不在
try except
中包装大量内容(捕捉
wx.\u core.wxAssertionError
是一个非常坏的习惯,因为它们通常是致命的),如何防止此错误

编辑:

该错误可在以下位置复制:

操作系统:Win 10 Enterprise 2016 LTSB/Win 10 Pro(在两个平台上都进行了测试)

wxPython版本和来源:4.0.2/4.0.3,来自pip3(在两者上都进行了测试)


Python版本和来源:Python 3.6.5股票

这是wxPython的一个bug,将在未来的版本中修复


可以在此处跟踪该问题:

看起来正在使用该功能。它在使用wx 4.0.3的Linux上运行良好,但在使用4.0.1时,该选项不存在,而是提供了
Insert Emoji
。最佳猜测,上移到>=wx 4.0。3@RolfofSaxony我将wxPython更新为4.0.3,错误仍然存在,可能是Windows特有的
wx._core.wxAssertionError: C++ assertion "m_menuDepth > 0" failed at ..\..\src\msw\toplevel.cpp(1545) in wxTopLevelWindowMSW::DoSendMenuOpenCloseEvent(): No open menus?

The above exception was the direct cause of the following exception:

SystemError: <class 'wx._core.CommandEvent'> returned a result with an error set
import wx


class Program(wx.Frame):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.panel = wx.Panel(self)
        self.sizer = wx.GridBagSizer(0, 0)
        self.panel.SetSizer(self.sizer)

        self.text_ctrl = wx.TextCtrl(self.panel)
        self.sizer.Add(self.text_ctrl, wx.GBPosition(0, 0))

        # Needed, because there probably has to be some events which
        # can be processed for the error to show before closing the program.
        # Without this the error only appears after exiting.
        self.text_ctrl.Bind(wx.EVT_TEXT, lambda e: print("text changed"))

        self.sizer.Layout()
        self.Show()


app = wx.App()
program = Program(parent=None)
app.MainLoop()