Handling a few exceptions when no file is loaded.
authorTom Rondeau <trondeau@vt.edu>
Wed, 16 Sep 2009 14:03:29 +0000 (10:03 -0400)
committerTom Rondeau <trondeau@vt.edu>
Wed, 16 Sep 2009 14:03:29 +0000 (10:03 -0400)
gr-utils/src/python/gr_plot_qt.py

index 267737fd0c535e57626b29fa9c39d0900d9722e5..581dc6d332bc3462ca24745197ab476bc2a15672 100755 (executable)
@@ -64,9 +64,12 @@ class SpectrogramData(Qwt.QwtRasterData):
         return Qwt.QwtDoubleInterval(self.sp.min(), self.sp.max())
 
     def value(self, x, y):
-        f = int(self.freq.searchsorted(x))
-        t = int(self.time.searchsorted(y))
-        return self.sp[f][t-1]
+        try:
+            f = int(self.freq.searchsorted(x))
+            t = int(self.time.searchsorted(y))
+            return self.sp[f][t-1]
+        except AttributeError: # if no file loaded yet
+            return 0
 
 
 class gr_plot_qt(QtGui.QMainWindow):
@@ -451,7 +454,11 @@ class gr_plot_qt(QtGui.QMainWindow):
 
         # If there's a non-digit character, reset box
         else:
-            self.set_file_pos_box(self.cur_start, self.cur_stop)
+            try:
+                self.set_file_pos_box(self.cur_start, self.cur_stop)
+            except AttributeError:
+                pass
+            
 
     def file_time_changed(self):
         tstart = self.gui.fileTimeStartLineEdit.text().toDouble()