我在尝试打开下面的GUI时遇到问题,并收到如下所示的错误。我已经将问题缩小到下面代码的那一部分,我将每个条目包含各种rgb像素强度的信息转换成一个~1.7毫米大小的数组到一个1300x1340像素大小的图片中,以及一些简单的线条图。
这是我收到的错误(当我将Frame&#39的显示设置为True时会发生错误):
2014-07-05 11:31:52.234 python[79783:707] Exception detected while handling key input.
2014-07-05 11:31:52.235 python[79783:707] Unlocking Focus on wrong view (<wxNSView: 0x10a66ced0>), expected <wxNSView: 0x10a671280>
2014-07-05 11:31:52.243 python[79783:707] (
0 CoreFoundation 0x00007fff8edc6b06 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff973923f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8edc68dc +[NSException raise:format:]
+ 204
3 AppKit 0x00007fff92f8b430 -[NSView unlockFocus] + 213
4 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c24751d
_ZN24wxMacCoreGraphicsContext16SetNativeContextEP9CGContext + 253
5 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c249854
_ZN24wxMacCoreGraphicsContextD0Ev + 36
6 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c3073d3 _ZN10wxGCDCImplD2Ev + 51
7 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c243917 _ZN14wxClientDCImplD0Ev + 71
8 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c30203c _ZN10wxClientDCD0Ev + 44
9 _gdi_.so 0x000000010d44dbfb _wrap_delete_DC + 107
10 _gdi_.so 0x000000010d40baf4 PySwigObject_dealloc + 644
11 libpython2.7.dylib 0x000000010005599f dict_dealloc + 175
12 libpython2.7.dylib 0x0000000100078a72 subtype_dealloc + 1154
13 libpython2.7.dylib 0x000000010003e67f frame_dealloc + 495
14 libpython2.7.dylib 0x00000001000ca310 PyEval_EvalCodeEx + 656
15 libpython2.7.dylib 0x0000000100040192 function_call + 178
16 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
17 libpython2.7.dylib 0x000000010001f5b1 instancemethod_call + 401
18 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
19 libpython2.7.dylib 0x00000001000c19e7 PyEval_CallObjectWithKeywords +
87
20 _core_.so 0x000000010b40f768
_ZN12wxPyCallback12EventThunkerER7wxEvent + 312
21 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ac4d4
_ZN12wxEvtHandler23ProcessEventIfMatchesIdERK21wxEventTableEntryBasePS_R7wxEvent + 84
22 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ad5cf
_ZN12wxEvtHandler23SearchDynamicEventTableER7wxEvent + 111
23 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae738
_ZN12wxEvtHandler11TryHereOnlyER7wxEvent + 40
24 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae7eb
_ZN12wxEvtHandler19ProcessEventLocallyER7wxEvent + 59
25 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae855
_ZN12wxEvtHandler12ProcessEventER7wxEvent + 69
26 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae386
_ZN12wxEvtHandler18SafelyProcessEventER7wxEvent + 22
27 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c3ec200
_ZNK12wxWindowBase17HandleWindowEventER7wxEvent + 16
28 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1f35b9 _ZN8wxWindow11MacDoRedrawEl +
857
29 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c2cf4c5
_ZN17wxWidgetCocoaImpl8drawRectEPvP6NSViewS0_ + 629
30 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c2cfb96
_Z14wxOSX_drawRectP6NSViewP13objc_selector6CGRect + 358
31 AppKit 0x00007fff92f7e064 -[NSView _drawRect:clip:] +
4217
32 AppKit 0x00007fff92f7c6c1 -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1656
33 AppKit 0x00007fff92f7cad9 -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2704
34 AppKit 0x00007fff92f7a6f2 -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
+ 817
35 AppKit 0x00007fff92f7a143 -[NSThemeFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
+ 314
36 AppKit 0x00007fff92f75d6d -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 4675
37 AppKit 0x00007fff92f3fc93 -[NSView displayIfNeeded] + 1830
38 AppKit 0x00007fff92ffca18 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 1377
39 AppKit 0x00007fff92ffc038 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 940
40 AppKit 0x00007fff92ffbc1f -[NSWindow orderWindow:relativeTo:] + 159
41 AppKit 0x00007fff92ff46dc -[NSWindow makeKeyAndOrderFront:] + 48
42 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c2b91c8 _ZN25wxNonOwnedWindowCocoaImpl4ShowEb + 872
43 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1e7341 _ZN16wxNonOwnedWindow4ShowEb + 65
44 _core_.so 0x000000010b486691 _wrap_Window_Show + 257
45 libpython2.7.dylib 0x00000001000c897b PyEval_EvalFrameEx + 24347
46 libpython2.7.dylib 0x00000001000ca743 PyEval_EvalCodeEx + 1731
47 libpython2.7.dylib 0x00000001000c8866 PyEval_EvalFrameEx + 24070
48 libpython2.7.dylib 0x00000001000ca743 PyEval_EvalCodeEx + 1731
49 libpython2.7.dylib 0x0000000100040192 function_call + 178
50 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
51 libpython2.7.dylib 0x000000010001f5b1 instancemethod_call + 401
52 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
53 libpython2.7.dylib 0x000000010007cac8 slot_tp_init + 88
54 libpython2.7.dylib 0x000000010007b0fc type_call + 188
55 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
56 libpython2.7.dylib 0x00000001000c6b74 PyEval_EvalFrameEx + 16660
57 libpython2.7.dylib 0x00000001000ca743 PyEval_EvalCodeEx + 1731
58 libpython2.7.dylib 0x0000000100040192 function_call + 178
59 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
60 libpython2.7.dylib 0x000000010001f5b1 instancemethod_call + 401
61 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
62 libpython2.7.dylib 0x00000001000c19e7 PyEval_CallObjectWithKeywords + 87
63 _core_.so 0x000000010b40f768
_ZN12wxPyCallback12EventThunkerER7wxEvent + 312
64 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ac4d4
_ZN12wxEvtHandler23ProcessEventIfMatchesIdERK21wxEventTableEntryBasePS_R7wxEvent + 84
65 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ad5cf
_ZN12wxEvtHandler23SearchDynamicEventTableER7wxEvent + 111
66 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae738
_ZN12wxEvtHandler11TryHereOnlyER7wxEvent + 40
67 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae7eb
_ZN12wxEvtHandler19ProcessEventLocallyER7wxEvent + 59
68 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae855
_ZN12wxEvtHandler12ProcessEventER7wxEvent + 69
69 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c3ed274
_ZN12wxWindowBase8TryAfterER7wxEvent + 116
70 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae933
_ZN12wxEvtHandler12ProcessEventER7wxEvent + 291
71 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae386
_ZN12wxEvtHandler18SafelyProcessEventER7wxEvent + 22
72 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c3ec200
_ZNK12wxWindowBase17HandleWindowEventER7wxEvent + 16
73 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c22ddfb
_ZN10wxTextCtrl6OnCharER10wxKeyEvent + 1595
74 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ac4d4
_ZN12wxEvtHandler23ProcessEventIfMatchesIdERK21wxEventTableEntryBasePS_R7wxEvent + 84
75 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae694
_ZN16wxEventHashTable11HandleEventER7wxEventP12wxEvtHandler + 132
76 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae756
_ZN12wxEvtHandler11TryHereOnlyER7wxEvent + 70
77 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae7eb
_ZN12wxEvtHandler19ProcessEventLocallyER7wxEvent + 59
78 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae855
_ZN12wxEvtHandler12ProcessEventER7wxEvent + 69
79 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1ae386
_ZN12wxEvtHandler18SafelyProcessEventER7wxEvent + 22
80 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c3ec200
_ZNK12wxWindowBase17HandleWindowEventER7wxEvent + 16
81 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1f7b43
_ZN8wxWindow17OSXHandleKeyEventER10wxKeyEvent + 51
82 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c2cfd2d
_ZN17wxWidgetCocoaImpl17DoHandleCharEventEP7NSEventP8NSString + 205
83 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c2bfd28 -[wxNSTextFieldEditor
insertText:] + 120
84 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c2c093d -[wxNSTextField
control:textView:doCommandBySelector:] + 141
85 AppKit 0x00007fff92e37e64 -[NSTextField
textView:doCommandBySelector:] + 96
86 AppKit 0x00007fff92e37da8 -[NSTextView
doCommandBySelector:] + 159
87 AppKit 0x00007fff92ebae6e -[
NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:]
+ 2200
88 AppKit 0x00007fff92eba2db -[NSTextInputContext
handleEvent:] + 939
89 AppKit 0x00007fff92eb9ea7 -[NSView interpretKeyEvents:] +
183
90 AppKit 0x00007fff92e06c97 -[NSTextView keyDown:] + 723
91 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c2bfebf -[wxNSTextFieldEditor keyDown:]
+ 111
92 AppKit 0x00007fff93022020 -[NSWindow sendEvent:] + 9687
93 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c2b82dc -[wxNSWindow sendEvent:] + 140
94 AppKit 0x00007fff9301d644 -[NSApplication sendEvent:] +
5761
95 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1c099a -[wxNSApplication sendEvent:] +
74
96 AppKit 0x00007fff92f3321a -[NSApplication run] + 636
97 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c2aa3b8 _ZN14wxGUIEventLoop8OSXDoRunEv
+ 248
98 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c1782af _ZN13wxCFEventLoop5DoRunEv + 31
99 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c0b0751 _ZN15wxEventLoopBase3RunEv + 65
100 libwx_osx_cocoau-3.0.0.0.0.dylib 0x000000010c075d97
_ZN16wxAppConsoleBase8MainLoopEv + 103
101 _core_.so 0x000000010b40641c _ZN7wxPyApp8MainLoopEv + 76
102 _core_.so 0x000000010b450d4f _wrap_PyApp_MainLoop + 79
103 libpython2.7.dylib 0x00000001000c897b PyEval_EvalFrameEx + 24347
104 libpython2.7.dylib 0x00000001000ca743 PyEval_EvalCodeEx + 1731
105 libpython2.7.dylib 0x0000000100040192 function_call + 178
106 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
107 libpython2.7.dylib 0x000000010001f5b1 instancemethod_call + 401
108 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
109 libpython2.7.dylib 0x00000001000c6b74 PyEval_EvalFrameEx + 16660
110 libpython2.7.dylib 0x00000001000c924b PyEval_EvalFrameEx + 26603
111 libpython2.7.dylib 0x00000001000ca743 PyEval_EvalCodeEx + 1731
112 libpython2.7.dylib 0x0000000100040192 function_call + 178
113 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
114 libpython2.7.dylib 0x000000010001f5b1 instancemethod_call + 401
115 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
116 libpython2.7.dylib 0x000000010007cac8 slot_tp_init + 88
117 libpython2.7.dylib 0x000000010007b0fc type_call + 188
118 libpython2.7.dylib 0x000000010000ccb2 PyObject_Call + 98
119 libpython2.7.dylib 0x00000001000c6b74 PyEval_EvalFrameEx + 16660
120 libpython2.7.dylib 0x00000001000ca743 PyEval_EvalCodeEx + 1731
121 libpython2.7.dylib 0x00000001000caa36 PyEval_EvalCode + 54
122 libpython2.7.dylib 0x00000001000f026b PyRun_InteractiveOneFlags + 379
123 libpython2.7.dylib 0x00000001000f04ae PyRun_InteractiveLoopFlags + 78
124 libpython2.7.dylib 0x00000001000f05ee PyRun_AnyFileExFlags + 126
125 libpython2.7.dylib 0x0000000100107c05 Py_Main + 3029
126 python 0x0000000100000f54 start + 52
)
&gt;
&GT; 以下是相关代码:
def OnPaint(self, event):
Image1 = wx.ClientDC(self.file1Image)
Image2 = wx.ClientDC(self.file2Image)
Image3 = wx.ClientDC(self.trajectory)
Image1.Clear()
Image2.Clear()
Image3.Clear()
first = int(self.editFirstFileNum.GetValue()) - 1
second = int(self.editSecondFileNum.GetValue()) - 1
conversionFactor = 500
array1 = self.beam[first].cleanArray
array2 = self.beam[second].cleanArray
for i in range (0, len(array1)):
red1 = blue1 = green1 = np.abs(array1[i][2] / conversionFactor) #Grayscale (no pun intended)
red2 = blue2 = green2 = np.abs(array2[i][2] / conversionFactor)
Image1.SetPen(wx.Pen(wx.Colour(red1, blue1, green1)))
Image1.DrawPoint(np.abs(array1[i][0]), np.abs(array2[i][1]))
Image2.SetPen(wx.Pen(wx.Colour(red2, blue2, green2)))
Image2.DrawPoint(np.abs(array1[i][0]), np.abs(array2[i][1]))
if i % 100000 == 0:
print(i)
print("okay!")
x1 = self.beam[first].center[0]
y1 = self.beam[first].center[1]
x2 = self.beam[second].center[0]
y2 = self.beam[second].center[1]
Image1.SetPen(wx.RED_PEN)
Image1.DrawPoint(x1, y1)
Image2.SetPen(wx.CYAN_PEN)
Image2.DrawPoint(x2, y2)
print("okay!")
for i in range (first - 1, second + 1):
Image3.SetPen(wx.GREEN_PEN)
Image3.DrawPoint(self.beam[i].center[0] , self.beam[i].center[1])
if i < second:
Image3.DrawLine(self.beam[i].center[0] , self.beam[i].centerIntensity[1],
self.beam[i + 1].center[0] , self.beam[i + 1].centerIntensity[1])