Python 每次我单击wx.Frame或按键盘上的键时,EVT_CLOSE就会被触发

Python 每次我单击wx.Frame或按键盘上的键时,EVT_CLOSE就会被触发,python,wxpython,wxwidgets,Python,Wxpython,Wxwidgets,每次运行python脚本时,我都在运行以下类: class MySplashScreen(wx.SplashScreen): def OnSplashScreenExit(self,e): self.Hide(); frame = MyFrame(None) def __init__(self,parent=None): if "linux" in sys.platform or "darwin" in sys.platform:

每次运行python脚本时,我都在运行以下类:

class MySplashScreen(wx.SplashScreen):
    def OnSplashScreenExit(self,e):
        self.Hide();
        frame = MyFrame(None)

    def __init__(self,parent=None):
        if "linux" in sys.platform or "darwin" in sys.platform:       
             bmp = wx.Bitmap(PATH + '/../icons/DNA.png', wx.BITMAP_TYPE_PNG)
        elif "win" in sys.platform and not 'darwin' in sys.platform:      
             bmp = wx.Bitmap(PATH + '\..\icons\DNA.png', wx.BITMAP_TYPE_PNG)       

        wx.SplashScreen.__init__(self,bmp,wx.SPLASH_CENTER_ON_SCREEN | wx.SPLASH_TIMEOUT,SPLASH_TIMEOUT,parent)
        self.Bind(wx.EVT_CLOSE,self.OnSplashScreenExit)

但当我点击MyFrame上的任意位置时,另一个MyFrames就会打开。在调试过程中,我发现每当我单击MyFrame上的任意位置或按键盘上的任意键时,OnSplashScreenExit函数都会运行。有人能帮我修一下吗。这个问题在linux中是不可产生的。它只出现在使用python2.7系统的windows 8.1上。

我可以通过进行以下更改来修复它:

if "win" in sys.platform:
         self.OnSplashScreenExit("")
else:
         self.Bind(wx.EVT_CLOSE,self.OnSplashScreenExit)

您正在OnSplashScreenExit中创建MyFrame,这就解释了为什么飞溅关闭时框架会打开。您是否也在其他地方创建MyFrame?看到一个正在运行的示例会有所帮助