Initial import.
* fluent: The application program. * system: The core system. * workflows: Directory for workflow modules.
This commit is contained in:
parent
bb246a77d7
commit
5853216df4
117
fluent
Executable file
117
fluent
Executable file
@ -0,0 +1,117 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
sys.path.append('system')
|
||||
sys.path.append('workflows')
|
||||
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
import gtk.gdk
|
||||
import gtk.glade
|
||||
import gnome
|
||||
import gnome.ui
|
||||
import pango
|
||||
import workflow
|
||||
import logger
|
||||
import plots
|
||||
import navigator
|
||||
|
||||
PROGRAM_NAME = 'fluent'
|
||||
VERSION = '0.1.0'
|
||||
GLADEFILENAME = 'system/fluent.glade'
|
||||
APP = 'appwindow'
|
||||
WF_BOX = 'workflow_vbox'
|
||||
DATA_BOX = 'data_vbox'
|
||||
|
||||
class FluentApp:
|
||||
|
||||
def __init__(self):
|
||||
# Application variables
|
||||
self.navigator = navigator.NavigatorStore()
|
||||
self.current_data = None
|
||||
|
||||
gtk.glade.set_custom_handler(self.custom_object_factory)
|
||||
self.widget_tree = gtk.glade.XML(GLADEFILENAME, APP)
|
||||
self.workflow = workflow.EinarsWorkflow(self)
|
||||
|
||||
def custom_object_factory(self, glade, function_name, widget_name,\
|
||||
str1, str2, int1, int2):
|
||||
handler = getattr(self, function_name)
|
||||
return handler(str1, str2, int1, int2)
|
||||
|
||||
def create_logview(self, str1, str2, int1, int2):
|
||||
# Set up log view
|
||||
self.log_view = logger.LogView(logger.logger)
|
||||
self.log_view.show()
|
||||
return self.log_view
|
||||
|
||||
def create_navigator_view(self, str1, str2, int1, int2):
|
||||
self.navigator_view = navigator.NavigatorView(self.navigator, self)
|
||||
self.navigator_view.show()
|
||||
return self.navigator_view
|
||||
|
||||
def show(self):
|
||||
self.init_gui()
|
||||
|
||||
def init_gui(self):
|
||||
self.app = self.widget_tree.get_widget(APP)
|
||||
self.app.set_size_request(800, 600)
|
||||
|
||||
# Set up workflow
|
||||
wf_box = self.widget_tree.get_widget(WF_BOX)
|
||||
wf_menu = workflow.WorkflowView(self.workflow)
|
||||
wf_menu.show()
|
||||
wf_box.pack_end(wf_menu)
|
||||
|
||||
# Set up plot
|
||||
pt = self.widget_tree.get_widget('plot_table')
|
||||
plot = plots.SinePlot()
|
||||
plot.show()
|
||||
plot.mark_active(True)
|
||||
pt.add(plot)
|
||||
|
||||
plot2 = plots.EmptyPlot()
|
||||
plot2.show()
|
||||
pt.attach(plot2, 1, 2, 0, 1)
|
||||
|
||||
plot3 = plots.EmptyPlot()
|
||||
plot3.show()
|
||||
pt.attach(plot3, 0, 1, 1, 2)
|
||||
|
||||
plot4 = plots.EmptyPlot()
|
||||
plot4.show()
|
||||
pt.attach(plot4, 1, 2, 1, 2)
|
||||
|
||||
# Set up plot toolbar
|
||||
dock = self.widget_tree.get_widget('plot_toolbar_dock')
|
||||
dock.add(plot.get_toolbar(self.app))
|
||||
|
||||
# Connect signals
|
||||
signals = {'on_quit1_activate' : (gtk.main_quit),
|
||||
'on_appwindow_delete_event' : (gtk.main_quit),
|
||||
'on_view_log_activate' : (self.toggle_view_log)}
|
||||
self.widget_tree.signal_autoconnect(signals)
|
||||
|
||||
# Log that we've set up the app now
|
||||
logger.log('debug', 'Program started')
|
||||
|
||||
def change_plot(self, plot):
|
||||
pt = self.widget_tree.get_widget('plot_table')
|
||||
pt.attach(plot, 1, 2, 1, 2)
|
||||
|
||||
def toggle_view_log(self, menu_item):
|
||||
lw = self.widget_tree.get_widget('logview')
|
||||
if menu_item.get_active():
|
||||
lw.show()
|
||||
else:
|
||||
lw.unparent()
|
||||
logger.log('debug', 'Toggling log window visibility')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
gnome.program_init(PROGRAM_NAME, VERSION)
|
||||
app = FluentApp()
|
||||
app.show()
|
||||
gtk.main()
|
||||
|
581
system/fluent.glade
Normal file
581
system/fluent.glade
Normal file
@ -0,0 +1,581 @@
|
||||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
<requires lib="gnome"/>
|
||||
<requires lib="bonobo"/>
|
||||
|
||||
<widget class="GnomeApp" id="appwindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Fluent</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="default_width">800</property>
|
||||
<property name="default_height">600</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="enable_layout_config">True</property>
|
||||
<signal name="delete_event" handler="on_appwindow_delete_event" last_modification_time="Thu, 13 Apr 2006 18:54:58 GMT"/>
|
||||
|
||||
<child internal-child="dock">
|
||||
<widget class="BonoboDock" id="bonobodock1">
|
||||
<property name="visible">True</property>
|
||||
<property name="allow_floating">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="BonoboDockItem" id="bonobodockitem1">
|
||||
<property name="visible">True</property>
|
||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuBar" id="menubar1">
|
||||
<property name="visible">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="file1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_FILE_TREE</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenu" id="file1_menu">
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="new1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_NEW_ITEM</property>
|
||||
<property name="label" translatable="yes">_Ny</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_new1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="open1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_OPEN_ITEM</property>
|
||||
<signal name="activate" handler="on_open1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="save1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_SAVE_ITEM</property>
|
||||
<signal name="activate" handler="on_save1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="save_as1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_SAVE_AS_ITEM</property>
|
||||
<signal name="activate" handler="on_save_as1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkSeparatorMenuItem" id="separator1">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="quit1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_EXIT_ITEM</property>
|
||||
<signal name="activate" handler="on_quit1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="edit1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_EDIT_TREE</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenu" id="edit1_menu">
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="cut1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_CUT_ITEM</property>
|
||||
<signal name="activate" handler="on_cut1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="copy1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_COPY_ITEM</property>
|
||||
<signal name="activate" handler="on_copy1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="paste1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_PASTE_ITEM</property>
|
||||
<signal name="activate" handler="on_paste1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="clear1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_CLEAR_ITEM</property>
|
||||
<signal name="activate" handler="on_clear1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkSeparatorMenuItem" id="separator2">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="properties1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_PROPERTIES_ITEM</property>
|
||||
<signal name="activate" handler="on_properties1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkSeparatorMenuItem" id="separator3">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="preferences1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_PREFERENCES_ITEM</property>
|
||||
<signal name="activate" handler="on_preferences1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="view1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_VIEW_TREE</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenu" id="view1_menu">
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckMenuItem" id="view_log">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Log</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<signal name="activate" handler="on_view_log_activate" last_modification_time="Sat, 15 Apr 2006 10:37:30 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="help1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_HELP_TREE</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenu" id="help1_menu">
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="about1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_ABOUT_ITEM</property>
|
||||
<signal name="activate" handler="on_about1_activate" last_modification_time="Thu, 13 Apr 2006 11:24:18 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="placement">BONOBO_DOCK_TOP</property>
|
||||
<property name="band">0</property>
|
||||
<property name="position">0</property>
|
||||
<property name="offset">0</property>
|
||||
<property name="behavior">BONOBO_DOCK_ITEM_BEH_EXCLUSIVE|BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL|BONOBO_DOCK_ITEM_BEH_LOCKED</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="BonoboDockItem" id="bonobodockitem2">
|
||||
<property name="visible">True</property>
|
||||
<property name="shadow_type">GTK_SHADOW_OUT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolbar" id="toolbar1">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
|
||||
<property name="toolbar_style">GTK_TOOLBAR_ICONS</property>
|
||||
<property name="tooltips">True</property>
|
||||
<property name="show_arrow">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="toolbutton1">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Ny fil</property>
|
||||
<property name="stock_id">gtk-new</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
<property name="is_important">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="toolbutton2">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Åpne fil</property>
|
||||
<property name="stock_id">gtk-open</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
<property name="is_important">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="toolbutton3">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Lagre fil</property>
|
||||
<property name="stock_id">gtk-save</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
<property name="is_important">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="placement">BONOBO_DOCK_TOP</property>
|
||||
<property name="band">1</property>
|
||||
<property name="position">0</property>
|
||||
<property name="offset">2</property>
|
||||
<property name="behavior">BONOBO_DOCK_ITEM_BEH_NORMAL</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="BonoboDockItem" id="bonobodockitem3">
|
||||
<property name="visible">True</property>
|
||||
<property name="shadow_type">GTK_SHADOW_OUT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolbar" id="toolbar2">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
|
||||
<property name="toolbar_style">GTK_TOOLBAR_ICONS</property>
|
||||
<property name="tooltips">True</property>
|
||||
<property name="show_arrow">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="toolbutton4">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_id">gtk-zoom-in</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
<property name="is_important">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="toolbutton5">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_id">gtk-zoom-out</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
<property name="is_important">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="placement">BONOBO_DOCK_TOP</property>
|
||||
<property name="band">1</property>
|
||||
<property name="position">1</property>
|
||||
<property name="offset">0</property>
|
||||
<property name="behavior">BONOBO_DOCK_ITEM_BEH_NORMAL</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="BonoboDockItem" id="plot_toolbar_dock">
|
||||
<property name="visible">True</property>
|
||||
<property name="shadow_type">GTK_SHADOW_OUT</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="placement">BONOBO_DOCK_TOP</property>
|
||||
<property name="band">1</property>
|
||||
<property name="position">2</property>
|
||||
<property name="offset">0</property>
|
||||
<property name="behavior">BONOBO_DOCK_ITEM_BEH_NORMAL</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVPaned" id="vpaned1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="position">300</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHPaned" id="hpaned1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="position">700</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHPaned" id="hpaned2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="position">200</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="data_vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><b>Navigator</b></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="Custom" id="navigator_view">
|
||||
<property name="visible">True</property>
|
||||
<property name="creation_function">create_navigator_view</property>
|
||||
<property name="int1">0</property>
|
||||
<property name="int2">0</property>
|
||||
<property name="last_modification_time">Sat, 15 Apr 2006 12:34:23 GMT</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="shrink">False</property>
|
||||
<property name="resize">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTable" id="plot_table">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">2</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="row_spacing">3</property>
|
||||
<property name="column_spacing">3</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="shrink">True</property>
|
||||
<property name="resize">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="shrink">True</property>
|
||||
<property name="resize">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="workflow_vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label14">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><b>Workflow</b></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="shrink">False</property>
|
||||
<property name="resize">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="shrink">True</property>
|
||||
<property name="resize">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkNotebook" id="notebook1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="show_tabs">True</property>
|
||||
<property name="show_border">True</property>
|
||||
<property name="tab_pos">GTK_POS_TOP</property>
|
||||
<property name="scrollable">False</property>
|
||||
<property name="enable_popup">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="Custom" id="logview">
|
||||
<property name="visible">True</property>
|
||||
<property name="creation_function">create_logview</property>
|
||||
<property name="int1">0</property>
|
||||
<property name="int2">0</property>
|
||||
<property name="last_modification_time">Fri, 14 Apr 2006 20:23:55 GMT</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Log</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="shrink">True</property>
|
||||
<property name="resize">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child internal-child="appbar">
|
||||
<widget class="GnomeAppBar" id="appbar1">
|
||||
<property name="visible">True</property>
|
||||
<property name="has_progress">True</property>
|
||||
<property name="has_status">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
145
system/logger.py
Normal file
145
system/logger.py
Normal file
@ -0,0 +1,145 @@
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import time
|
||||
|
||||
class Logger:
|
||||
def __init__(self):
|
||||
self.store = gtk.ListStore(gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
self.levels = ['debug', 'notice', 'warning', 'error']
|
||||
self.level_text = {'debug': 'Debug',
|
||||
'notice': 'Notice',
|
||||
'warning': 'Warning',
|
||||
'error': 'Error'}
|
||||
self.components = {}
|
||||
self.colors = { 'debug': 'grey',
|
||||
'notice': 'black',
|
||||
'warning': 'brown',
|
||||
'error': 'red' }
|
||||
|
||||
def log(self, level, message):
|
||||
iter = self.store.append()
|
||||
self.store.set_value(iter, 0, level)
|
||||
self.store.set_value(iter, 1, message)
|
||||
self.store.set_value(iter, 2, self.colors[level])
|
||||
|
||||
class LogView(gtk.TreeView):
|
||||
|
||||
def __init__(self, logger=None, level='notice'):
|
||||
self.logger = logger
|
||||
self.model = logger.store
|
||||
|
||||
|
||||
# Set up filter
|
||||
self.filter = self.model.filter_new()
|
||||
gtk.TreeView.__init__(self, self.filter)
|
||||
self.filter.set_visible_func(self.level_filter)
|
||||
self.set_level(level)
|
||||
|
||||
|
||||
# Set up log level column
|
||||
renderer = gtk.CellRendererText()
|
||||
self.level_col = gtk.TreeViewColumn('Level', renderer, text=0)
|
||||
self.level_col.add_attribute(renderer, "foreground", 2)
|
||||
self.append_column(self.level_col)
|
||||
|
||||
# Set up message column
|
||||
renderer = gtk.CellRendererText()
|
||||
self.message_col = gtk.TreeViewColumn('Message', renderer, text=1)
|
||||
self.message_col.add_attribute(renderer, "foreground", 2)
|
||||
self.append_column(self.message_col)
|
||||
|
||||
# Activate context menu
|
||||
self.menu = LogMenu(self.logger, self)
|
||||
self.connect('popup_menu', self.popup_menu)
|
||||
self.connect('button_press_event', self.mouse_popup_menu)
|
||||
#self.connect('button_release_event', None)
|
||||
|
||||
def set_level(self, level):
|
||||
self.level = level
|
||||
self.level_no = self.logger.levels.index(level)
|
||||
self.filter.refilter()
|
||||
self.queue_draw()
|
||||
|
||||
def popup_menu(self, *rest):
|
||||
self.menu.popup(None, None, None, 0, 0)
|
||||
|
||||
def mouse_popup_menu(self, widget, event):
|
||||
if event.button == 3:
|
||||
self.menu.popup(None, None, None, event.button, event.time)
|
||||
|
||||
def level_filter(self, store, iter):
|
||||
if store.get_value(iter,0):
|
||||
value = self.logger.levels.index(store.get_value(iter, 0))
|
||||
return value >= self.level_no
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
class LogLevelMenu(gtk.Menu):
|
||||
def __init__(self, logger, view):
|
||||
self.logger = logger
|
||||
self.view = view
|
||||
items = []
|
||||
gtk.Menu.__init__(self)
|
||||
|
||||
for level in logger.levels:
|
||||
if len(items) == 0:
|
||||
group = None
|
||||
else:
|
||||
group = items[0]
|
||||
item = gtk.RadioMenuItem(group, logger.level_text[level], level)
|
||||
item.connect('activate', self.set_log_level, level)
|
||||
items.append(item)
|
||||
self.append(item)
|
||||
item.show()
|
||||
items[0].set_active(True)
|
||||
|
||||
def set_log_level(self, widget, level, *rest):
|
||||
if widget.active:
|
||||
self.view.set_level(level)
|
||||
|
||||
class LogComponentMenu(gtk.Menu):
|
||||
def __init__(self, logger, view):
|
||||
gtk.Menu.__init__(self)
|
||||
components = logger.components.keys()
|
||||
components.sort(str.__gt__)
|
||||
|
||||
for c in components:
|
||||
item = gtk.MenuItem(c)
|
||||
self.append(item)
|
||||
item.show()
|
||||
|
||||
# for component in logger.components
|
||||
class LogMenu(gtk.Menu):
|
||||
def __init__(self, logger, view):
|
||||
gtk.Menu.__init__(self)
|
||||
self.logger = logger
|
||||
|
||||
# View Log Level
|
||||
self.view_menu = LogLevelMenu(logger, view)
|
||||
self.view_item = gtk.MenuItem('View Log Level')
|
||||
self.view_item.set_submenu(self.view_menu)
|
||||
self.append(self.view_item)
|
||||
self.view_item.show()
|
||||
|
||||
# View Components
|
||||
self.component_menu = LogComponentMenu(logger, view)
|
||||
self.component_item = gtk.MenuItem('View Components')
|
||||
self.component_item.set_submenu(self.component_menu)
|
||||
self.append(self.component_item)
|
||||
self.component_item.show()
|
||||
|
||||
# Clear Log
|
||||
clear_item = gtk.MenuItem('Clear Log')
|
||||
clear_item.connect('activate', self.activate_clear_button)
|
||||
self.append(clear_item)
|
||||
clear_item.show()
|
||||
|
||||
def activate_clear_button(self, item):
|
||||
self.logger.store.clear()
|
||||
|
||||
logger = Logger()
|
||||
log = logger.log
|
47
system/navigator.py
Normal file
47
system/navigator.py
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import plots
|
||||
import logger
|
||||
|
||||
class NavigatorStore (gtk.TreeStore):
|
||||
def __init__(self):
|
||||
gtk.TreeStore.__init__(self, gobject.TYPE_STRING, plots.Plot)
|
||||
|
||||
iter = self.append(None)
|
||||
self.set_value(iter, 0, ('Sine Plot'))
|
||||
self.set_value(iter, 1, (plots.SinePlot()))
|
||||
|
||||
iter = self.append(None)
|
||||
self.set_value(iter, 0, ('Sine Plot 1'))
|
||||
self.set_value(iter, 1, (plots.EmptyPlot()))
|
||||
|
||||
def plot_at(self, path):
|
||||
iter = self.get_iter(path)
|
||||
plot = self.get_value(iter, 1)
|
||||
if plot:
|
||||
plot.show()
|
||||
return plot
|
||||
|
||||
class NavigatorView (gtk.TreeView):
|
||||
def __init__(self, nav, app):
|
||||
gtk.TreeView.__init__(self, nav)
|
||||
self.navigator = nav
|
||||
self.app = app
|
||||
|
||||
self.set_headers_visible(False)
|
||||
self.connect('row-activated', self.row_activated_handler)
|
||||
|
||||
renderer = gtk.CellRendererText()
|
||||
self.object_col = gtk.TreeViewColumn('Object', renderer, text=0)
|
||||
self.append_column(self.object_col)
|
||||
|
||||
logger.log('debug', 'Initializing naviagor window')
|
||||
|
||||
def row_activated_handler(self, widget, path, column):
|
||||
#self.app.change_window(
|
||||
#
|
||||
|
||||
plot = self.navigator.plot_at(path)
|
||||
logger.log('notice', 'Button pressed')
|
||||
self.app.change_plot(plot)
|
71
system/plots.py
Normal file
71
system/plots.py
Normal file
@ -0,0 +1,71 @@
|
||||
|
||||
import pygtk
|
||||
import gtk
|
||||
import matplotlib
|
||||
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
|
||||
from matplotlib.axes import Subplot
|
||||
from matplotlib.figure import Figure
|
||||
from matplotlib.numerix import arange, sin, pi
|
||||
from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar
|
||||
import scipy
|
||||
import logger
|
||||
|
||||
class Plot (gtk.Frame):
|
||||
|
||||
def __init__(self):
|
||||
gtk.Frame.__init__(self)
|
||||
self.canvas = None
|
||||
self.mark_active(False)
|
||||
self.connect('button_press_event', self.on_button_press)
|
||||
|
||||
def on_button_press(self, *rest):
|
||||
logger.log('debug', 'button pressed in plot')
|
||||
self.mark_active(True)
|
||||
|
||||
def get_toolbar(self, window):
|
||||
self.toolbar = NavigationToolbar(self.canvas, window)
|
||||
self.toolbar.set_property('show-arrow', False)
|
||||
return self.toolbar
|
||||
|
||||
def mark_active(self, active):
|
||||
if active:
|
||||
self.set_shadow_type(gtk.SHADOW_IN)
|
||||
else:
|
||||
self.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
||||
|
||||
|
||||
class EmptyPlot (Plot):
|
||||
def __init__(self):
|
||||
Plot.__init__(self)
|
||||
label = gtk.Label('No plot')
|
||||
label.show()
|
||||
self.add(label)
|
||||
|
||||
def get_toolbar(self, window):
|
||||
return None
|
||||
|
||||
class SinePlot (Plot):
|
||||
|
||||
def __init__(self):
|
||||
Plot.__init__(self)
|
||||
fig = Figure(figsize=(5,4), dpi=72)
|
||||
ax = fig.add_subplot(111)
|
||||
t = arange(0.0,3.0,0.01)
|
||||
s = sin(2*pi*t)
|
||||
ax.plot(t,s)
|
||||
self.canvas = FigureCanvas(fig)
|
||||
self.add(self.canvas)
|
||||
self.canvas.show()
|
||||
|
||||
class ScatterPlot (Plot):
|
||||
def __init__(self):
|
||||
Plot.__init__(self)
|
||||
fig = Figure(figsize=(5,4), dpi=72)
|
||||
ax = fig.add_subplot(111)
|
||||
t = arange(0.0, 3.0, 0.01)
|
||||
a = scipy.randn(200, 300)
|
||||
fig.plot(a)
|
||||
self.canvas = FigureCanvas(fig)
|
||||
self.add(self.canvas)
|
||||
self.canvas.show()
|
||||
|
123
system/workflow.py
Normal file
123
system/workflow.py
Normal file
@ -0,0 +1,123 @@
|
||||
|
||||
import gtk
|
||||
import logger
|
||||
|
||||
class Workflow:
|
||||
"""Defines a workflow that contains a set of analysis stages.
|
||||
|
||||
A Workflow is a set of analysis stages for a certain type of analysis.
|
||||
Each stage contains some possible operations to do accomplish that
|
||||
task.
|
||||
"""
|
||||
|
||||
def __init__(self, app):
|
||||
self.name = ''
|
||||
self.stages = []
|
||||
self.stages_by_id = {}
|
||||
self.app = app
|
||||
|
||||
def add_stage(self, stage):
|
||||
self.stages.append(stage)
|
||||
self.stages_by_id[stage.id] = stage
|
||||
|
||||
def print_tree(self):
|
||||
print self.name
|
||||
for stage in self.stages:
|
||||
print ' %s' % stage.name
|
||||
for fun in stage.functions:
|
||||
print ' %s' % fun.name
|
||||
|
||||
class Stage:
|
||||
"""A stage is a part of the data analysis process.
|
||||
|
||||
Each stage contains a set of functions that can be used to
|
||||
accomplish the task. A typical early stage is 'preprocessing', which
|
||||
can be done in several ways, each represented by a function.
|
||||
"""
|
||||
|
||||
def __init__(self, id, name):
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.functions = []
|
||||
self.functions_by_id = {}
|
||||
|
||||
def add_function(self, fun):
|
||||
self.functions.append(fun)
|
||||
self.functions_by_id[fun.id] = fun
|
||||
|
||||
class Function:
|
||||
"""A Function object encapsulates a function on a data set.
|
||||
|
||||
Each Function instance encapsulates some function that can be applied
|
||||
to one or more types of data.
|
||||
"""
|
||||
|
||||
def __init__(self, id, name):
|
||||
self.id = id
|
||||
self.name = name
|
||||
|
||||
def valid_input(input):
|
||||
return True
|
||||
|
||||
def run(self, data):
|
||||
pass
|
||||
|
||||
def foo():
|
||||
print "foo"
|
||||
|
||||
class EinarsWorkflow (Workflow):
|
||||
|
||||
def __init__(self, app):
|
||||
Workflow.__init__(self, app)
|
||||
self.name = 'Einar\'s Workflow'
|
||||
|
||||
load = Stage('load', 'Load Data')
|
||||
load.add_function(Function('load', 'Load Microarrays'))
|
||||
self.add_stage(load)
|
||||
|
||||
preproc = Stage('preprocess', 'Preprocessing')
|
||||
preproc.add_function(Function('rma', 'RMA'))
|
||||
self.add_stage(preproc)
|
||||
|
||||
go = Stage('go', 'Gene Ontology Data')
|
||||
go.add_function(Function('godist', 'GO Distances'))
|
||||
self.add_stage(go)
|
||||
|
||||
regression = Stage('regression', 'Regression')
|
||||
regression.add_function(Function('pls', 'PLS'))
|
||||
self.add_stage(regression)
|
||||
|
||||
logger.log('debug', 'Einar\'s workflow is now active')
|
||||
|
||||
class WorkflowView (gtk.VBox):
|
||||
|
||||
def __init__(self, wf):
|
||||
gtk.VBox.__init__(self)
|
||||
self.workflow = wf
|
||||
|
||||
# Add stage in the process
|
||||
for stage in wf.stages:
|
||||
exp = gtk.Expander(stage.name)
|
||||
btn_box = gtk.VBox()
|
||||
btn_box.show()
|
||||
exp.add(btn_box)
|
||||
|
||||
# Add functions in each stage
|
||||
for fun in stage.functions:
|
||||
btn = gtk.Button(fun.name)
|
||||
btn.connect('clicked', self.button_click_handler)
|
||||
# btn.connect('clicked', lambda(w): logger.log('notice', fun.name))
|
||||
btn.function = fun
|
||||
|
||||
btn_box.add(btn)
|
||||
btn.show()
|
||||
|
||||
exp.show()
|
||||
self.pack_start(exp, expand=False, fill=False)
|
||||
|
||||
def button_click_handler(self, button):
|
||||
function = button.function
|
||||
logger.log('debug', 'Starting function: %s' % function.name)
|
||||
function.run(self.workflow.app.current_data)
|
||||
logger.log('debug', 'Function ended: %s' % function.name)
|
||||
|
Reference in New Issue
Block a user