Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Fixed function output bug. Datasets now appear as children of their first parent, also in gtk 2.10

This commit is contained in:
Einar Ryeng 2007-01-03 13:05:37 +00:00
parent c34f23190b
commit 75447d8840
2 changed files with 19 additions and 23 deletions

View File

@ -19,6 +19,8 @@ class NavigatorView (gtk.TreeView):
# various properties
self.set_headers_visible(False)
self.get_hadjustment().set_value(0)
self.set_enable_tree_lines(True)
# Selection Mode
self.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
self.get_selection().set_select_function(self.is_selectable)

View File

@ -8,9 +8,12 @@ import dataset, plots
class Project:
def __init__(self,name="Testing"):
self.data_tree = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_PYOBJECT, gobject.TYPE_STRING,
gobject.TYPE_STRING, gobject.TYPE_OBJECT,
self.data_tree = gtk.TreeStore(gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_PYOBJECT,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_OBJECT,
gobject.TYPE_DOUBLE)
self.name = name
@ -22,6 +25,7 @@ class Project:
self.sel_obj = dataset.Selection('Current Selection')
self.selections = []
self._last_selection = None
self._dataset_iter_map = {}
def add_selection_observer(self, observer):
self._selection_observers.append(observer)
@ -51,21 +55,6 @@ class Project:
def get_selection(self):
"""Returns the current selection object"""
return self.sel_obj
def get_data_iter(self, obj):
"""Retuns an iterator to data."""
retval = [None]
if obj:
# add data below first function data input
obj=obj[0]
def is_obj(m, p, i, d):
if obj == m.get_value(i, 2):
d.append(i)
return True
self.data_tree.foreach(is_obj, retval)
return retval[-1]
def add_data(self, parents, data, fun='Function'):
"""Adds a set of data and plots to the navigator.
@ -73,15 +62,19 @@ class Project:
This method is usually called after a Function in a workflow
has finished and returns its output."""
parent_iter = self.get_data_iter(parents)
icon_fname = os.path.join(fluents.ICONDIR,"folder_grey.png")
if len(parents) > 0:
parent_iter = self._dataset_iter_map[parents[0]]
else:
parent_iter = None
icon_fname = os.path.join(fluents.ICONDIR, "folder_grey.png")
icon = gtk.gdk.pixbuf_new_from_file(icon_fname)
it = self.data_tree_insert(parent_iter, fun, None, None,"black",icon)
it = self.data_tree_insert(parent_iter, fun, None, None, "black", icon)
for d in data:
if isinstance(d, dataset.GraphDataset):
self.add_dataset(d)
icon_fname = os.path.join(fluents.ICONDIR,"graph_dataset.png")
icon_fname = os.path.join(fluents.ICONDIR, "graph_dataset.png")
icon = gtk.gdk.pixbuf_new_from_file(icon_fname)
self.data_tree_insert(it, d.get_name(), d, None, "black",icon)
elif isinstance(d,dataset.CategoryDataset):
@ -103,7 +96,7 @@ class Project:
elif isinstance(d, dataset.Selection):
self.add_selection(d)
def data_tree_insert(self, parent, text, data, bgcolour,fontcolour,icon,selected = 0):
def data_tree_insert(self, parent, text, data, bgcolour, fontcolour, icon, selected = 0):
tree = self.data_tree
it = tree.append(parent)
tree.set_value(it, 0, text)
@ -113,6 +106,7 @@ class Project:
tree.set_value(it, 4, fontcolour)
tree.set_value(it, 5, icon)
tree.set_value(it, 6, selected)
self._dataset_iter_map[data] = it
return it
def add_dataset(self, dataset):