OK Button crashes in wxPython

2019-09-09 20:46发布

问题:

I'm working on XP and using WX python As GUI library. Recently I look a lot of problems, for example If I Use a @MikeDriscoll 's example the code at the second print the python interpreter crashes, and I don't know why and how track this error (more important)...

import wx

########################################################################
class SampleDialog(wx.Dialog):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Dialog.__init__(self, parent, title="Tutorial")
        print "Hello Here"
        btnOk = wx.Button(self, wx.ID_OK)
        print "Hello Here"
        btnCancel = wx.Button(self, wx.ID_CANCEL)
        btnSizer = wx.StdDialogButtonSizer()
        btnSizer.AddButton(btnOk)
        btnSizer.AddButton(btnCancel)
        btnSizer.Realize()
        self.SetSizer(btnSizer)

#----------------------------------------------------------------------
if __name__ == '__main__':
    app = wx.App(False)
    dlg = SampleDialog(None)
    dlg.ShowModal()