Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Added "Plot" submenu in navigator context menu. Can create an ImagePlot of a dataset.

This commit is contained in:
Einar Ryeng 2007-01-17 14:06:07 +00:00
parent c3c6e85044
commit 06591e301e
1 changed files with 30 additions and 5 deletions

View File

@ -162,6 +162,7 @@ class NavigatorView (gtk.TreeView):
def on_mouse_event(self, widget, event):
path = widget.get_path_at_pos(int(event.x), int(event.y))
iter = None
if path:
iter = self.data_tree.get_iter(path[0])
@ -170,9 +171,9 @@ class NavigatorView (gtk.TreeView):
obj = None
if isinstance(obj, dataset.Dataset):
self.menu.set_dataset(obj)
self.menu.set_dataset(obj, iter)
else:
self.menu.set_dataset(None)
self.menu.set_dataset(None, iter)
if event.button == 3:
self.menu.popup(None, None, None, event.button, event.time)
@ -183,7 +184,8 @@ class NavigatorMenu(gtk.Menu):
gtk.Menu.__init__(self)
self.navigaotor = navigator
self.dataset = None
self.tree_iter = None
# Populate menu
self.load_item = gtk.MenuItem('Load dataset')
self.load_item.connect('activate', self.on_load_dataset, navigator)
@ -195,13 +197,29 @@ class NavigatorMenu(gtk.Menu):
self.append(self.save_item)
self.save_item.show()
def set_dataset(self, ds):
# Build plot menu
self.plot_menu = gtk.Menu()
self.plot_image_item = gtk.MenuItem('Image Plot')
self.plot_image_item.connect('activate', self.on_plot_image, navigator)
self.plot_menu.append(self.plot_image_item)
self.plot_image_item.show()
self.plot_item = gtk.MenuItem('Plot')
self.append(self.plot_item)
self.plot_item.set_submenu(self.plot_menu)
self.plot_item.show()
def set_dataset(self, ds, it):
self.dataset = ds
self.tree_iter = it
if ds == None:
self.save_item.set_property('sensitive', False)
self.plot_item.set_property('sensitive', False)
else:
self.save_item.set_property('sensitive', True)
self.plot_item.set_property('sensitive', True)
def on_load_dataset(self, item, navigator):
dialog = gtk.FileChooserDialog('Load dataset')
@ -248,3 +266,10 @@ class NavigatorMenu(gtk.Menu):
print "unknown; ", retval
dialog.destroy()
def on_plot_image(self, item, navigator):
project = navigator.project
plot = plots.ImagePlot(self.dataset, name='Image Plot')
icon = fluents.icon_factory.get("line_plot")
project.data_tree_insert(self.tree_iter, 'Image Plot', plot, None, "black", icon)