Fixed function output bug. Datasets now appear as children of their first parent, also in gtk 2.10
This commit is contained in:
parent
c34f23190b
commit
75447d8840
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
@ -52,36 +56,25 @@ class Project:
|
|||
"""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.
|
||||
|
||||
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):
|
||||
|
|
Reference in New Issue