Catch exceptions and display in a dialog box
This commit is contained in:
parent
c8566b9516
commit
8606daad08
|
@ -208,12 +208,17 @@ class Frame(wx.Frame):
|
||||||
self.SetSizerAndFit(vb)
|
self.SetSizerAndFit(vb)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
|
|
||||||
if len(self.devs) > 0:
|
d1 = None
|
||||||
|
while (d1 is None) and (len(self.devs) > 0):
|
||||||
if preferred in self.devs:
|
if preferred in self.devs:
|
||||||
d1 = preferred
|
d1 = preferred
|
||||||
else:
|
else:
|
||||||
d1 = min(self.devs)
|
d1 = min(self.devs)
|
||||||
|
try:
|
||||||
self.connect(self.devs[d1])
|
self.connect(self.devs[d1])
|
||||||
|
except serial.SerialException:
|
||||||
|
del self.devs[d1]
|
||||||
|
d1 = None
|
||||||
cb.SetValue(d1)
|
cb.SetValue(d1)
|
||||||
|
|
||||||
t = threading.Thread(target=ping_thr, args=(self, ))
|
t = threading.Thread(target=ping_thr, args=(self, ))
|
||||||
|
@ -338,6 +343,13 @@ class Frame(wx.Frame):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app = wx.App(0)
|
app = wx.App(0)
|
||||||
|
try:
|
||||||
f = Frame(*sys.argv[1:])
|
f = Frame(*sys.argv[1:])
|
||||||
f.Show(True)
|
f.Show(True)
|
||||||
app.MainLoop()
|
app.MainLoop()
|
||||||
|
except:
|
||||||
|
import sys, traceback
|
||||||
|
xc = traceback.format_exception(*sys.exc_info())
|
||||||
|
dlg = wx.MessageDialog(None, "".join(xc), "i2cgui Error Trap", wx.OK | wx.ICON_WARNING)
|
||||||
|
dlg.ShowModal()
|
||||||
|
dlg.Destroy()
|
||||||
|
|
Loading…
Reference in New Issue