Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

* system/plots.py, system/fluent.glade: There is now an active plot.

This commit is contained in:
Einar Ryeng 2006-04-17 20:27:39 +00:00
parent 3668481562
commit 494aedc1b5
4 changed files with 216 additions and 41 deletions

44
fluent
View File

@ -47,6 +47,16 @@ class FluentApp:
self.log_view.show() self.log_view.show()
return self.log_view return self.log_view
def create_small_view(self, str1, str2, int1, int2):
self.small_view = plots.SmallView()
self.small_view.show()
return self.small_view
def create_large_view(self, str1, str2, int1, int2):
self.large_view = plots.LargeView()
self.large_view.show()
return self.large_view
def create_navigator_view(self, str1, str2, int1, int2): def create_navigator_view(self, str1, str2, int1, int2):
self.navigator_view = navigator.NavigatorView(self.navigator, self) self.navigator_view = navigator.NavigatorView(self.navigator, self)
self.navigator_view.show() self.navigator_view.show()
@ -66,23 +76,11 @@ class FluentApp:
wf_box.pack_end(wf_menu) wf_box.pack_end(wf_menu)
# Set up plot # Set up plot
pt = self.widget_tree.get_widget('plot_table') pt = self.widget_tree.get_widget('small_view')
plot = plots.SinePlot() plot = plots.SinePlot()
plot.show() plot.show()
plot.mark_active(True) plot.mark_active(True)
pt.add(plot) # pt.set_child(plot, 0, 1)
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 # Set up plot toolbar
dock = self.widget_tree.get_widget('plot_toolbar_dock') dock = self.widget_tree.get_widget('plot_toolbar_dock')
@ -91,15 +89,20 @@ class FluentApp:
# Connect signals # Connect signals
signals = {'on_quit1_activate' : (gtk.main_quit), signals = {'on_quit1_activate' : (gtk.main_quit),
'on_appwindow_delete_event' : (gtk.main_quit), 'on_appwindow_delete_event' : (gtk.main_quit),
'on_view_log_activate' : (self.toggle_view_log)} 'on_view_log_activate' : (self.toggle_view_log),
'on_zoom_in_button_clicked' : (self.on_single_view),
'on_zoom_out_button_clicked' : (self.on_multiple_view)}
self.widget_tree.signal_autoconnect(signals) self.widget_tree.signal_autoconnect(signals)
# Log that we've set up the app now # Log that we've set up the app now
logger.log('debug', 'Program started') logger.log('debug', 'Program started')
def change_plot(self, plot): def change_plot(self, plot):
pt = self.widget_tree.get_widget('plot_table') pt = self.widget_tree.get_widget('small_view')
pt.attach(plot, 1, 2, 1, 2) pt.set_child(plot, 1, 1)
# plot.hide()
# pt.remove(plot)
# plot.unparent()
def toggle_view_log(self, menu_item): def toggle_view_log(self, menu_item):
lw = self.widget_tree.get_widget('logview') lw = self.widget_tree.get_widget('logview')
@ -109,6 +112,13 @@ class FluentApp:
lw.unparent() lw.unparent()
logger.log('debug', 'Toggling log window visibility') logger.log('debug', 'Toggling log window visibility')
def on_single_view(self, button):
nb = self.widget_tree.get_widget('view_notebook')
nb.set_current_page(1)
def on_multiple_view(self, button):
nb = self.widget_tree.get_widget('view_notebook')
nb.set_current_page(0)
if __name__ == '__main__': if __name__ == '__main__':
gnome.program_init(PROGRAM_NAME, VERSION) gnome.program_init(PROGRAM_NAME, VERSION)

View File

@ -305,12 +305,13 @@
<property name="show_arrow">False</property> <property name="show_arrow">False</property>
<child> <child>
<widget class="GtkToolButton" id="toolbutton4"> <widget class="GtkToolButton" id="zoom_in_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock_id">gtk-zoom-in</property> <property name="stock_id">gtk-zoom-in</property>
<property name="visible_horizontal">True</property> <property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property> <property name="visible_vertical">True</property>
<property name="is_important">False</property> <property name="is_important">False</property>
<signal name="clicked" handler="on_zoom_in_button_clicked" last_modification_time="Mon, 17 Apr 2006 19:52:20 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -319,12 +320,13 @@
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="toolbutton5"> <widget class="GtkToolButton" id="zoom_out_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock_id">gtk-zoom-out</property> <property name="stock_id">gtk-zoom-out</property>
<property name="visible_horizontal">True</property> <property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property> <property name="visible_vertical">True</property>
<property name="is_important">False</property> <property name="is_important">False</property>
<signal name="clicked" handler="on_zoom_out_button_clicked" last_modification_time="Mon, 17 Apr 2006 19:52:40 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -432,13 +434,79 @@
</child> </child>
<child> <child>
<widget class="GtkTable" id="plot_table"> <widget class="GtkNotebook" id="view_notebook">
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">2</property> <property name="show_tabs">False</property>
<property name="n_columns">2</property> <property name="show_border">False</property>
<property name="homogeneous">True</property> <property name="tab_pos">GTK_POS_TOP</property>
<property name="row_spacing">3</property> <property name="scrollable">False</property>
<property name="column_spacing">3</property> <property name="enable_popup">False</property>
<child>
<widget class="Custom" id="small_view">
<property name="visible">True</property>
<property name="creation_function">create_small_view</property>
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Mon, 17 Apr 2006 15:44:29 GMT</property>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="label" translatable="yes">label15</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.449999988079</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>
<child>
<widget class="Custom" id="large_view">
<property name="visible">True</property>
<property name="creation_function">create_large_view</property>
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Mon, 17 Apr 2006 15:44:42 GMT</property>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="label" translatable="yes">label16</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> </widget>
<packing> <packing>
<property name="shrink">True</property> <property name="shrink">True</property>

View File

@ -14,7 +14,7 @@ class NavigatorStore (gtk.TreeStore):
iter = self.append(None) iter = self.append(None)
self.set_value(iter, 0, ('Sine Plot 1')) self.set_value(iter, 0, ('Sine Plot 1'))
self.set_value(iter, 1, (plots.EmptyPlot())) self.set_value(iter, 1, (plots.EmptyView()))
def plot_at(self, path): def plot_at(self, path):
iter = self.get_iter(path) iter = self.get_iter(path)
@ -39,9 +39,6 @@ class NavigatorView (gtk.TreeView):
logger.log('debug', 'Initializing naviagor window') logger.log('debug', 'Initializing naviagor window')
def row_activated_handler(self, widget, path, column): def row_activated_handler(self, widget, path, column):
#self.app.change_window(
#
plot = self.navigator.plot_at(path) plot = self.navigator.plot_at(path)
logger.log('notice', 'Button pressed') logger.log('notice', 'Button pressed')
self.app.change_plot(plot) self.app.change_plot(plot)

View File

@ -10,11 +10,90 @@ from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationT
import scipy import scipy
import logger import logger
class SmallView (gtk.Table):
def __init__(self):
gtk.Table.__init__(self, 2, 2, True)
self.child_views = [[EmptyView(), EmptyView()],
[EmptyView(), EmptyView()]]
self.cols = 2
self.rows = 2
self.active_x = 0
self.active_y = 0
for x in range(self.cols):
for y in range(self.rows):
child = self.child_views[x][y]
child.parent_signalling = child.connect('button_press_event', self.__view_button_event__)
self.attach(child, x, x+1, y, y+1)
def set_child(self, child, col, row):
cur_widget = self.child_views[col][row]
cur_widget.disconnect(cur_widget.parent_signalling)
self.remove(cur_widget)
self.attach(child, col, col+1, row, row+1)
child.parent_signalling = child.connect('button_press_event', self.__view_button_event__)
self.child_views[col][row] = child
child.show()
def remove_child(self, col, row):
self.remove(selv.child_views[col, row])
self.attach(col, row, EmptyView())
def show(self):
for x in self.child_views:
for y in x:
y.show()
gtk.Table.show(self)
def hide(self):
for x in self.child_views:
for y in x:
y.hide()
gtk.Table.hide(self)
def set_active(self, x, y):
old_focus = self.child_views[self.active_x][self.active_y]
new_focus = self.child_views[x][y]
old_focus.mark_active(False)
new_focus.mark_active(True)
self.active_x = x
self.active_y = y
def find_child(self, child):
for i, row in enumerate(self.child_views):
for j, v in enumerate(row):
if v == child:
return (i, j)
return None
def __view_button_event__(self, view, *rest):
loc = self.find_child(view)
if loc:
self.set_active(loc[0], loc[1])
class LargeView (gtk.Frame):
def __init__(self):
gtk.Frame.__init__(self)
self.child_view = EmptyView()
self.add(self.child_view)
def set_child(self, child):
pass
def hide(self):
self.child_view.hide()
gtk.Frame.hide(self)
def show(self):
self.child_view.show()
gtk.Frame.show(self)
class Plot (gtk.Frame): class Plot (gtk.Frame):
def __init__(self): def __init__(self):
gtk.Frame.__init__(self) gtk.Frame.__init__(self)
self.canvas = None
self.mark_active(False) self.mark_active(False)
self.connect('button_press_event', self.on_button_press) self.connect('button_press_event', self.on_button_press)
@ -23,9 +102,7 @@ class Plot (gtk.Frame):
self.mark_active(True) self.mark_active(True)
def get_toolbar(self, window): def get_toolbar(self, window):
self.toolbar = NavigationToolbar(self.canvas, window) return None
self.toolbar.set_property('show-arrow', False)
return self.toolbar
def mark_active(self, active): def mark_active(self, active):
if active: if active:
@ -33,19 +110,32 @@ class Plot (gtk.Frame):
else: else:
self.set_shadow_type(gtk.SHADOW_ETCHED_IN) self.set_shadow_type(gtk.SHADOW_ETCHED_IN)
class EmptyView (Plot):
class EmptyPlot (Plot):
def __init__(self): def __init__(self):
Plot.__init__(self) Plot.__init__(self)
label = gtk.Label('No plot')
label.show() label = gtk.Label('No view')
self.add(label) ebox = gtk.EventBox()
ebox.add(label)
self.add(ebox)
label.connect('button_press_event', self.on_button_press)
def get_toolbar(self, window): self.label = label
return None self.ebox = ebox
self.show()
def show(self):
self.ebox.show()
self.label.show()
Plot.show(self)
def hide(self):
self.label.hide()
self.ebox.hide()
Plot.hide(self)
class SinePlot (Plot): class SinePlot (Plot):
def __init__(self): def __init__(self):
Plot.__init__(self) Plot.__init__(self)
fig = Figure(figsize=(5,4), dpi=72) fig = Figure(figsize=(5,4), dpi=72)
@ -57,6 +147,11 @@ class SinePlot (Plot):
self.add(self.canvas) self.add(self.canvas)
self.canvas.show() self.canvas.show()
def get_toolbar(self, window):
self.toolbar = NavigationToolbar(self.canvas, window)
self.toolbar.set_property('show-arrow', False)
return self.toolbar
class ScatterPlot (Plot): class ScatterPlot (Plot):
def __init__(self): def __init__(self):
Plot.__init__(self) Plot.__init__(self)
@ -69,3 +164,8 @@ class ScatterPlot (Plot):
self.add(self.canvas) self.add(self.canvas)
self.canvas.show() self.canvas.show()
def get_toolbar(self, window):
self.toolbar = NavigationToolbar(self.canvas, window)
self.toolbar.set_property('show-arrow', False)
return self.toolbar