import gtk import gobject import plots import logger class NavigatorStore (gtk.TreeStore): def __init__(self): gtk.TreeStore.__init__(self, gobject.TYPE_STRING, plots.Plot) iter = self.append(None) self.set_value(iter, 0, ('Sine Plot')) self.set_value(iter, 1, (plots.SinePlot())) iter = self.append(None) self.set_value(iter, 0, ('Sine Plot 1')) self.set_value(iter, 1, (plots.EmptyView())) def plot_at(self, path): iter = self.get_iter(path) plot = self.get_value(iter, 1) if plot: plot.show() return plot class NavigatorView (gtk.TreeView): def __init__(self, nav, app): gtk.TreeView.__init__(self, nav) self.navigator = nav self.app = app self.set_headers_visible(False) self.connect('row-activated', self.row_activated_handler) renderer = gtk.CellRendererText() self.object_col = gtk.TreeViewColumn('Object', renderer, text=0) self.append_column(self.object_col) logger.log('debug', 'Initializing naviagor window') def row_activated_handler(self, widget, path, column): plot = self.navigator.plot_at(path) logger.log('notice', 'Button pressed') self.app.change_plot(plot)