Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

* system/dialogs.py: Oooops. Forgot this file in the previous commits. Well,

here it is, currently only with the New Project dialog.
This commit is contained in:
Einar Ryeng 2006-04-22 22:29:02 +00:00
parent 2da88a5128
commit e762aef882
5 changed files with 114 additions and 9 deletions

5
fluent
View File

@ -2,7 +2,6 @@
import sys
sys.path.append('system')
sys.path.append('workflows')
import dialogs
import pygtk
@ -19,8 +18,6 @@ import dataset
import logger
import plots
import navigator
#import go_workflow
#import pca_workflow
import scipy
PROGRAM_NAME = 'fluent'
@ -37,7 +34,6 @@ class FluentApp:
gtk.glade.set_custom_handler(self.custom_object_factory)
self.widget_tree = gtk.glade.XML(GLADEFILENAME, 'appwindow')
self.workflow = workflow.EmptyWorkflow(self)
# self.workflow.add_project(self.project)
def set_project(self, project):
logger.log('notice', 'Creating a new project')
@ -124,7 +120,6 @@ class FluentApp:
return self.widget_tree.get_widget(key)
def on_create_project(self, *rest):
logger.log('error', 'FIXME: Create project')
d = dialogs.CreateProjectDruid(self)
d.run()

111
system/dialogs.py Normal file
View File

@ -0,0 +1,111 @@
import pygtk
pygtk.require('2.0')
import gtk
import gobject
import logger
import project
import workflows
import workflow
import sys
import os
GLADEFILENAME = 'system/fluent.glade'
class CreateProjectDruid(gtk.Window):
"""A druid for creating a new project.
The CreateProjectDruid gets a list of all classes derived from
Workflow, and asks the user to select one of these. A new project of
the selected class is added to the application."""
def __init__(self, app):
gtk.Window.__init__(self)
self.app = app
self.widget_tree = gtk.glade.XML(GLADEFILENAME, 'new_project_druid')
self.workflows = self.make_workflow_list()
self.selected = None
renderer = gtk.CellRendererText()
wf_name = gtk.TreeViewColumn('Workflow Name', renderer, text=0)
self['workflow_list'].insert_column(wf_name, 0)
self.wf_info = gtk.TextBuffer()
self['workflow_info'].set_buffer(self.wf_info)
def workflow_classes(self, modname):
"""Returns a list of all subclasses of Workflow in a given module"""
workflow_classes = []
__import__('workflows.%s' % modname)
module = sys.modules['workflows.%s' % modname]
d = module.__dict__
for wf in d.values():
try:
if issubclass(wf, workflow.Workflow):
workflow_classes.append(wf)
except TypeError, e:
pass
return workflow_classes
def make_workflow_list(self):
"""Returns a ListStore containing all new workflows"""
store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
# List all .py files that can contain workflow classes
wf_path = sys.modules['workflows'].__path__
wf_files = []
for dir in wf_path:
for fn in os.listdir(dir):
if fn.endswith('.py'):
wf_files.append(fn[:-3])
# Try to load each file and look for Workflow derived classes
for fn in wf_files:
try:
wf_info = self.workflow_classes(fn)
for wf in wf_info:
store.insert_after(None, (getattr(wf, 'name'), wf))
except Exception, e:
logger.log('warning', 'Cannot load workflow: %s' % fn)
return store
def __getitem__(self, key):
return self.widget_tree.get_widget(key)
def run(self):
self['workflow_list'].set_model(self.workflows)
self['druidpagestart1'].show()
self['druidpagefinish1'].show()
self['new_project_druid'].show()
self['druidpagefinish1'].connect('finish', self.finish)
self['workflow_list'].connect('cursor_changed', self.selection_updated)
self.connect('destroy', self.delete)
def delete(self, widget):
return False
def hide(self):
self['druidpagestart1'].hide()
self['druidpagefinish1'].hide()
self['new_project_druid'].hide()
gtk.Window.hide(self)
def finish(self, *rest):
tree, it = self['workflow_list'].get_selection().get_selected()
wf = self.workflows.get_value(it, 1)
proj = project.Project()
self.app.set_workflow(wf(self.app))
self.app.set_project(proj)
self.hide()
self.destroy()
def selection_updated(self, *rest):
tree, it = self['workflow_list'].get_selection().get_selected()
wf = self.workflows.get_value(it, 1)
self.wf_info.set_text(wf.description)

View File

@ -637,7 +637,7 @@ The functions of the workflow you select will be available on the right part of
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>

View File

@ -11,6 +11,7 @@ class Workflow:
"""
name = "Workflow"
description = "Workflow Description"
def __init__(self, app):
self.stages = []
@ -100,7 +101,6 @@ class WorkflowView (gtk.VBox):
self.pack_start(exp, expand=False, fill=False)
def remove_workflow(self):
print self.get_children()
for c in self.get_children():
c.hide()
self.remove(c)
@ -109,8 +109,6 @@ class WorkflowView (gtk.VBox):
self.workflow = workflow
self.remove_workflow()
self.setup_workflow(workflow)
print workflow
logger.log('notice', 'Created new workflow')
def run_function(self, function):
logger.log('debug', 'Starting function: %s' % function.name)

View File

@ -12,6 +12,7 @@ import cPickle
class EinarsWorkflow (Workflow):
name = 'Test Workflow'
description = 'Gene Ontology Workflow. This workflow currently serves as a general testing workflow.'
def __init__(self, app):
Workflow.__init__(self, app)