summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2013-12-01 14:23:11 +0100
committerDavid Lamparter <equinox@diac24.net>2013-12-01 14:23:11 +0100
commit48a073ac505f97ffa1a2c3fe3476e0b97d70eff3 (patch)
tree67e6fd749dd0ec1d5e505393819a86fb3a93b71a
parent3d862d615ea2665ff65d4b68048889165005922b (diff)
fix some error cases
-rw-r--r--ptgui.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/ptgui.py b/ptgui.py
index 45046e2..4478493 100644
--- a/ptgui.py
+++ b/ptgui.py
@@ -7,6 +7,7 @@ ml = GLib.MainLoop()
import pttarget, ptlayout
from ptlayout import PTLText
import time
+import usb.core
class MainWindow(object):
def __init__(self):
@@ -84,18 +85,25 @@ class MainWindow(object):
def dev_select(self):
itr = self.devbox.get_active_iter()
+ if itr is None:
+ return
dev = self.devlist[itr][1]
dev.setup()
self.status_update()
def status_update(self):
itr = self.devbox.get_active_iter()
+ if itr is None:
+ return
dev = self.devlist[itr][1]
- if dev.last_status is None or time.time() - dev.last_status >= 1:
- dev.refresh_status()
- else:
- dev.check_status()
+ try:
+ if dev.last_status is None or time.time() - dev.last_status >= 1:
+ dev.refresh_status()
+ else:
+ dev.check_status()
+ except usb.core.USBError, e:
+ print 'problem while status refresh:', str(e)
if dev.err1 == 0 and dev.err2 == 0:
self.printbtn.set_sensitive(True)
@@ -181,6 +189,9 @@ class MainWindow(object):
ctx.fill()
def layout_update(self):
+ if self.label_surface is None:
+ return
+
w, h = self.layout.prep_size(self.label_surface.get_height())
if w < 32:
w = 32