2
我在wxPython
中創建了一個程序。它有一個EVT.ACTIVATE
其中觸發函數。一切正常,直到我在函數中添加一些條件。如果出現中頻條件,程序將顯示:'pythonw.exe'在退出時已停止工作。讓我來解釋一下代碼:程序在退出時崩潰
# partial code of my program
self.Bind(wx.EVT_ACTIVATE, self.Focus)
def FindButton(self, e):
Input = self.search.GetValue()
# starts a thread that queries a big database
t = ProcessThread(str(Input), self.output1, self.output2, self.Object, self.container)
t.start()
def Focus(self, e):
# handles the paste command when window gets activated
try:
if self.menu_clip.IsChecked(): # this is the condition that causes problems
self.search.SetValue('')
self.search.Paste()
self.FindButton(None)
except:
pass
看在Focus
功能.IsChecked
條件下,它會導致問題。想我怎麼確定?因爲當我刪除IF
條件程序工作得很好。所以我必須寫這樣的功能,防止錯誤:
def Focus(self, e):
# handles the paste command when window gets activated
try:
self.search.SetValue('')
self.search.Paste()
self.FindButton(None)
except:
pass
但我需要應用條件,使我的程序的用戶友好的,爲什麼我的程序停止退出時響應爲條件?錯誤的細節可能會有所幫助,所以我附上:
Problem signature:
Problem Event Name: APPCRASH
Application Name: pythonw.exe
Application Version: 0.0.0.0
Application Timestamp: 4f84a6ca
Fault Module Name: StackHash_0a9e
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Code: c0000005
Exception Offset: 4d8dcccc
OS Version: 6.1.7600.2.0.0.256.1
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
'self.menu_clip'是否定義在'if'的位置? – Werner 2014-11-24 10:43:03
@Werner是的。我已經找到了解決方案,我自己的答案給出。 – 2014-11-25 19:23:57