diff options
author | David Lamparter <equinox@diac24.net> | 2013-12-01 14:23:11 +0100 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2013-12-01 14:23:11 +0100 |
commit | 48a073ac505f97ffa1a2c3fe3476e0b97d70eff3 (patch) | |
tree | 67e6fd749dd0ec1d5e505393819a86fb3a93b71a | |
parent | 3d862d615ea2665ff65d4b68048889165005922b (diff) |
fix some error cases
-rw-r--r-- | ptgui.py | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -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 |