diff options
-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 |