From 70b35690d96a1af9799ddf43ab9bd69abca448a1 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 16 Sep 2009 10:03:29 -0400 Subject: Handling a few exceptions when no file is loaded. --- gr-utils/src/python/gr_plot_qt.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gr-utils/src/python/gr_plot_qt.py b/gr-utils/src/python/gr_plot_qt.py index 267737fd0..581dc6d33 100755 --- a/gr-utils/src/python/gr_plot_qt.py +++ b/gr-utils/src/python/gr_plot_qt.py @@ -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() -- cgit