Validation wxPython PropertyGrid SetPropertyValidator崩溃

Validation wxPython PropertyGrid SetPropertyValidator崩溃,validation,wxpython,propertygrid,Validation,Wxpython,Propertygrid,我正在尝试使用wxPython构建PropertyGrid。对于某些属性,我想对输入的值进行特定验证。但是,当我尝试使用SetPropertyValidator()时,当在目标属性字段中输入任何内容时,python崩溃,我已经查看了文档。下面是代码的精简版本。你知道我遗漏了什么吗 import wx import wx.propgrid as wxpg class TestPanel(wx.Panel): def __init__(self,parent): wx.Pa

我正在尝试使用wxPython构建PropertyGrid。对于某些属性,我想对输入的值进行特定验证。但是,当我尝试使用SetPropertyValidator()时,当在目标属性字段中输入任何内容时,python崩溃,我已经查看了文档。下面是代码的精简版本。你知道我遗漏了什么吗

import wx
import wx.propgrid as wxpg

class TestPanel(wx.Panel):
    def __init__(self,parent):
        wx.Panel.__init__(self,parent)
        self.SetSizer(wx.BoxSizer(wx.VERTICAL))
        self.pg = wxpg.PropertyGridManager(self,
                    style=wxpg.PG_SPLITTER_AUTO_CENTER |
                          wxpg.PG_AUTO_SORT |
                          wxpg.PG_TOOLBAR)

        # Show help as tooltips
        self.pg.SetExtraStyle(wxpg.PG_EX_HELP_AS_TOOLTIPS)
        self.pg.Append(wxpg.IntProperty("number"))
        p = self.pg.Append(wxpg.StringProperty("word"))
        self.pg.SetPropertyValidator(p,TestValidator())
        self.Bind(wxpg.EVT_PG_CHANGED, self.OnPropGridChanged)
        self.GetSizer().Add(self.pg,proportion=1,flag=wx.EXPAND)



class TestValidator(wx.PyValidator):
    def __init__(self):
        wx.PyValidator.__init__(self)

    def Clone(self):
        return TestValidator()

    def Validate(self,win):       
        return True

    def TransferToWindow(self):
        return True # Prevent wxDialog from complaining.

    def TransferFromWindow(self):
        return True # Prevent wxDialog from complaining.


class wxFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title)
        self.panel = TestPanel(self)
        self.Show(True)

if __name__ == "__main__":
    app = wx.App(False)
    frame = wxFrame(None, 'Property Validator')
    app.MainLoop()