This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
laydi/fluent

119 lines
3.2 KiB
Plaintext
Raw Normal View History

#!/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
import go_workflow
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 = go_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()