Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Added option page to option dialog

This commit is contained in:
Arnar Flatberg 2007-01-25 12:10:18 +00:00
parent 1c2c2c8895
commit 7a204a3426
1 changed files with 49 additions and 15 deletions

View File

@ -3,6 +3,7 @@ import sys
import os
import inspect
import logger
import fluents
def _workflow_classes(modname):
"""Returns a list of all subclasses of Workflow in a given module"""
@ -247,10 +248,10 @@ class OptionsDialog(gtk.Dialog):
self._options = options
self._data = data
self._editable = True
self.set_size_request(300,400)
self.set_size_request(550,450)
# create notebook
nb = gtk.Notebook()
self.nb = nb = gtk.Notebook()
# 1. page: input/output
#
@ -277,14 +278,19 @@ class OptionsDialog(gtk.Dialog):
output_frame.add(output_align)
# plots
plot_list = gtk.ListStore(gobject.TYPE_STRING,
gobject.TYPE_BOOLEAN)
plot_list = gtk.ListStore(str, 'gboolean', gtk.gdk.Pixbuf)
plot_treeview = gtk.TreeView(plot_list)
# Add plots
plot_icon = fluents.icon_factory.get('line_plot')
for plt, name, use in self._options['all_plots']:
plot_list.append((name, use))
plot_list.append((name, use, plot_icon))
# Renderer for icon
plot_icon = fluents.icon_factory.get('line_plot')
icon_renderer = gtk.CellRendererPixbuf()
icon_renderer.set_property('pixbuf', plot_icon)
# Renderer for active toggle.
active_renderer = gtk.CellRendererToggle()
active_renderer.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE)
@ -295,30 +301,36 @@ class OptionsDialog(gtk.Dialog):
title_renderer = gtk.CellRendererText()
title_renderer.set_property('mode', gtk.CELL_RENDERER_MODE_EDITABLE)
title_column = gtk.TreeViewColumn('Plot', title_renderer, text=0)
title_column.pack_start(icon_renderer, expand=False)
# Add columns to tree view.
plot_treeview.append_column(active_column)
plot_treeview.append_column(title_column)
## datasets
dataset_list = gtk.ListStore(gobject.TYPE_STRING,
gobject.TYPE_BOOLEAN)
dataset_list = gtk.ListStore(str, 'gboolean', gtk.gdk.Pixbuf)
dataset_treeview = gtk.TreeView(dataset_list)
# Add datasets
data_icon = fluents.icon_factory.get('dataset')
for dat, name, use in self._options['all_data']:
dataset_list.append((name, use))
dataset_list.append((name, use, data_icon))
# Renderer for icon
icon_renderer = gtk.CellRendererPixbuf()
icon_renderer.set_property('pixbuf', data_icon)
# Renderer for active toggle.
active_renderer = gtk.CellRendererToggle()
active_renderer.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE)
active_renderer.connect('toggled', toggled, dataset_list)
active_column = gtk.TreeViewColumn('Use', active_renderer, active=1)
# Renderer for plot title.
# Renderer for dataset title.
title_renderer = gtk.CellRendererText()
title_renderer.set_property('mode', gtk.CELL_RENDERER_MODE_EDITABLE)
title_column = gtk.TreeViewColumn('Dataset', title_renderer, text=0)
title_column.pack_start(icon_renderer, expand=False)
# Add columns to tree view.
dataset_treeview.append_column(active_column)
@ -335,7 +347,7 @@ class OptionsDialog(gtk.Dialog):
vbox1.add(output_frame)
# add vbox to notebook
nb.append_page(vbox1, gtk.Label("I/O"))
nb.insert_page(vbox1, gtk.Label("Input/Output"), 0)
self.vbox.add(nb)
#keep ref to liststores
@ -354,9 +366,9 @@ class OptionsDialog(gtk.Dialog):
def set_output(self):
# get marked output data
out_data = [item[0] for name, mark in self.dataset_list for item in self._options['all_data'] if mark==True and name==item[1]]
out_data = [item[0] for name, mark, ic in self.dataset_list for item in self._options['all_data'] if mark==True and name==item[1]]
# get marked plots
out_plots = [item[0] for name, mark in self.plot_list for item in self._options['all_plots'] if mark==True and name==item[1]]
out_plots = [item[0] for name, mark, ic in self.plot_list for item in self._options['all_plots'] if mark==True and name==item[1]]
# update options
self._options['out_data'] = out_data
self._options['out_plots'] = out_plots
@ -373,6 +385,28 @@ class OptionsDialog(gtk.Dialog):
def get_options(self):
return self._options
def add_page_from_glade(self, glade_file, widget_name, page_title):
"""Adds a new page(s) to the existing notebook.
The input widget (added as a page in notebook) is defined
in the glade file.
input:
glade_file -- path to glade file
widget_name -- name of widget from glade file
"""
try:
self.wTree = gtk.glade.XML(glade_file)
except:
logger.log('debug', 'Could not find glade file: %s' %glade_file)
widget = self.wTree.get_widget(widget_name)
win = widget.get_parent()
win.hide()
widget.unparent()
self.nb.insert_page(widget, gtk.Label(page_title), -1)
self.nb.set_current_page(0)
def toggled(renderer, path, store):
it = store.get_iter(path)
old_value = store.get_value(it, 1)