There is only one thread involved in a simple GUI app with wxPython Take a look at the following link.
How many threads are there in a simple GUI app?
-
15-10-2022 - |
Pergunta
I noticed that some Exceptions
are caught normally by the main thread except:
at the end of this code, and some other aren't (1/0
in OnButton
). Why ?
Does this mean that OnButton(self, evt)
is launched in another thread ?
How many threads are involved in a simple GUI app with wxPython ?
import wx
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, title="Test", size=(300, 300))
MyPanel(self)
class MyPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
button = wx.Button(self, wx.ID_ANY, "Test")
self.Bind(wx.EVT_BUTTON, self.OnButton)
#1/0 here this line would be handled by the try/except below
def OnButton(self, evt):
1/0 # when you click on button, why isn't this handled by the exception hanlder?
try:
app = wx.App(False)
MyFrame(None).Show()
app.MainLoop()
except Exception, e:
print 'Hello' + type(e).__name__
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow