From fa3b1182bca9de524a85dd06d6d310656fb0eb92 Mon Sep 17 00:00:00 2001 From: reidarst Date: Thu, 27 Apr 2006 15:51:25 +0000 Subject: [PATCH] Added font/bg colours to Navigator. (uses coloumns 3,4 in TreeModel, set in projects.py) --- system/navigator.py | 28 +++++++++++++++++++--------- system/project.py | 13 ++++++++----- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/system/navigator.py b/system/navigator.py index 0762bdb..60f4e3b 100644 --- a/system/navigator.py +++ b/system/navigator.py @@ -2,7 +2,7 @@ import gtk import gobject import plots -from system import dataset, logger, plots, project +from system import dataset, logger, plots, project, workflow class NavigatorView (gtk.TreeView): def __init__(self, project, app): @@ -13,16 +13,22 @@ class NavigatorView (gtk.TreeView): else: self.data_tree = None - gtk.TreeView.__init__(self) #, self.data_tree) + gtk.TreeView.__init__(self) self.set_headers_visible(False) self.connect('cursor_changed', self.cursor_changed_handler) self.connect('row_activated', self.row_activated_handler) - # self.connect('row_inserted', self.row_changed_handler) + + #pixrenderer = gtk.CellRendererPixbuf() + textrenderer = gtk.CellRendererText() + + self.object_col = gtk.TreeViewColumn('Object') + #self.object_col.pack_start(pixrenderer) + self.object_col.pack_start(textrenderer) + + self.object_col.set_attributes(textrenderer, cell_background=3, foreground = 4, text=0) - renderer = gtk.CellRendererText() - self.object_col = gtk.TreeViewColumn('Object', renderer, text=0) self.append_column(self.object_col) logger.log('debug', 'Initializing navigator window.') @@ -45,15 +51,19 @@ class NavigatorView (gtk.TreeView): t = type(obj) logger.log('debug', 'Selected datatype was %s. Don\'t know what to do.' % t) - # TreeView changed. Expand new items! + # TreeView changed. Set correct focus and colours def row_changed_handler(self, treestore, pos, iter): - obj = treestore.get_value(iter,2) - if not treestore.get_value(iter,2): + obj = treestore.get_value(iter,2) + type_= treestore.get_value(iter,1) + + if not (treestore.get_value(iter,2) or treestore.get_value(iter,1)): return + self.expand_to_path(pos) - if isinstance(treestore.get_value(iter,2),dataset.Dataset): + if isinstance(obj,dataset.Dataset): self.set_cursor(pos) + def display_data_info(self, data): dims = zip(data.get_dim_names(), data.shape) diff --git a/system/project.py b/system/project.py index c7d4eaf..452af37 100644 --- a/system/project.py +++ b/system/project.py @@ -8,7 +8,7 @@ class Project: def __init__(self,name="Testing"): self.data_tree = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, - gobject.TYPE_PYOBJECT) + gobject.TYPE_PYOBJECT,gobject.TYPE_STRING,gobject.TYPE_STRING) self.name = name self.dim_names = [] @@ -49,23 +49,26 @@ class Project: has finished and returns its output.""" parent_iter = self.get_data_iter(parent) - it = self.data_tree_insert(parent_iter, fun, None) + + it = self.data_tree_insert(parent_iter, fun, None, "grey","black") for d in data: if isinstance(d, dataset.Dataset): self.add_dataset(d) - self.data_tree_insert(it, d.get_name(), d) + self.data_tree_insert(it, d.get_name(), d, "white", "blue") elif isinstance(d, plots.Plot): - self.data_tree_insert(it, d.get_title(), d) + self.data_tree_insert(it, d.get_title(), d, "white", "dark green") d.set_selection_listener(self.set_selection) self._selection_observers.append(d) - def data_tree_insert(self, parent, text, data): + def data_tree_insert(self, parent, text, data, bgcolour,fontcolour): tree = self.data_tree it = tree.append(parent) tree.set_value(it, 0, text) tree.set_value(it, 1, type(data)) tree.set_value(it, 2, data) + tree.set_value(it, 3, bgcolour) + tree.set_value(it, 4, fontcolour) return it def add_dataset(self,dataset):