Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Added font/bg colours to Navigator. (uses coloumns 3,4 in TreeModel, set in projects.py)

This commit is contained in:
Reidar Strand Hagen 2006-04-27 15:51:25 +00:00
parent 8fd1f4ba83
commit fa3b1182bc
2 changed files with 27 additions and 14 deletions

View File

@ -2,7 +2,7 @@
import gtk import gtk
import gobject import gobject
import plots import plots
from system import dataset, logger, plots, project from system import dataset, logger, plots, project, workflow
class NavigatorView (gtk.TreeView): class NavigatorView (gtk.TreeView):
def __init__(self, project, app): def __init__(self, project, app):
@ -13,16 +13,22 @@ class NavigatorView (gtk.TreeView):
else: else:
self.data_tree = None self.data_tree = None
gtk.TreeView.__init__(self) #, self.data_tree) gtk.TreeView.__init__(self)
self.set_headers_visible(False) self.set_headers_visible(False)
self.connect('cursor_changed', self.cursor_changed_handler) self.connect('cursor_changed', self.cursor_changed_handler)
self.connect('row_activated', self.row_activated_handler) self.connect('row_activated', self.row_activated_handler)
# self.connect('row_inserted', self.row_changed_handler)
renderer = gtk.CellRendererText() #pixrenderer = gtk.CellRendererPixbuf()
self.object_col = gtk.TreeViewColumn('Object', renderer, text=0) 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)
self.append_column(self.object_col) self.append_column(self.object_col)
logger.log('debug', 'Initializing navigator window.') logger.log('debug', 'Initializing navigator window.')
@ -45,16 +51,20 @@ class NavigatorView (gtk.TreeView):
t = type(obj) t = type(obj)
logger.log('debug', 'Selected datatype was %s. Don\'t know what to do.' % t) 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): def row_changed_handler(self, treestore, pos, iter):
obj = treestore.get_value(iter,2) obj = treestore.get_value(iter,2)
if not 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 return
self.expand_to_path(pos) self.expand_to_path(pos)
if isinstance(treestore.get_value(iter,2),dataset.Dataset): if isinstance(obj,dataset.Dataset):
self.set_cursor(pos) self.set_cursor(pos)
def display_data_info(self, data): def display_data_info(self, data):
dims = zip(data.get_dim_names(), data.shape) dims = zip(data.get_dim_names(), data.shape)

View File

@ -8,7 +8,7 @@ class Project:
def __init__(self,name="Testing"): def __init__(self,name="Testing"):
self.data_tree = gtk.TreeStore(gobject.TYPE_STRING, self.data_tree = gtk.TreeStore(gobject.TYPE_STRING,
gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_PYOBJECT) gobject.TYPE_PYOBJECT,gobject.TYPE_STRING,gobject.TYPE_STRING)
self.name = name self.name = name
self.dim_names = [] self.dim_names = []
@ -49,23 +49,26 @@ class Project:
has finished and returns its output.""" has finished and returns its output."""
parent_iter = self.get_data_iter(parent) 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: for d in data:
if isinstance(d, dataset.Dataset): if isinstance(d, dataset.Dataset):
self.add_dataset(d) 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): 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) d.set_selection_listener(self.set_selection)
self._selection_observers.append(d) 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 tree = self.data_tree
it = tree.append(parent) it = tree.append(parent)
tree.set_value(it, 0, text) tree.set_value(it, 0, text)
tree.set_value(it, 1, type(data)) tree.set_value(it, 1, type(data))
tree.set_value(it, 2, data) tree.set_value(it, 2, data)
tree.set_value(it, 3, bgcolour)
tree.set_value(it, 4, fontcolour)
return it return it
def add_dataset(self,dataset): def add_dataset(self,dataset):