From a0d2c0d16d66eb10a8278c819b635c6d1b05a897 Mon Sep 17 00:00:00 2001 From: einarr Date: Mon, 17 Apr 2006 22:30:53 +0000 Subject: [PATCH] * fluent, system/plots.py: Switching between four and one view now sort of works. Still a bit buggy, and with messy code. --- fluent | 20 ++++++------ system/fluent.glade | 77 +++------------------------------------------ system/plots.py | 76 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 88 insertions(+), 85 deletions(-) diff --git a/fluent b/fluent index 495bd35..086ca15 100755 --- a/fluent +++ b/fluent @@ -47,6 +47,11 @@ class FluentApp: self.log_view.show() return self.log_view + def create_main_view(self, str1, str2, int1, int2): + self.main_view = plots.MainView() + self.main_view.show() + return self.main_view + def create_small_view(self, str1, str2, int1, int2): self.small_view = plots.SmallView() self.small_view.show() @@ -98,11 +103,8 @@ class FluentApp: logger.log('debug', 'Program started') def change_plot(self, plot): - pt = self.widget_tree.get_widget('small_view') - pt.set_child(plot, 1, 1) -# plot.hide() -# pt.remove(plot) -# plot.unparent() + pt = self.widget_tree.get_widget('main_view') + pt.insert_view(plot) def toggle_view_log(self, menu_item): lw = self.widget_tree.get_widget('logview') @@ -113,12 +115,12 @@ class FluentApp: 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) + nb = self.widget_tree.get_widget('main_view') + nb.goto_large() def on_multiple_view(self, button): - nb = self.widget_tree.get_widget('view_notebook') - nb.set_current_page(0) + nb = self.widget_tree.get_widget('main_view') + nb.goto_small() if __name__ == '__main__': gnome.program_init(PROGRAM_NAME, VERSION) diff --git a/system/fluent.glade b/system/fluent.glade index 3ff4956..f84a14a 100644 --- a/system/fluent.glade +++ b/system/fluent.glade @@ -434,79 +434,12 @@ - + True - False - False - GTK_POS_TOP - False - False - - - - True - create_small_view - 0 - 0 - Mon, 17 Apr 2006 15:44:29 GMT - - - False - True - - - - - - True - label15 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.449999988079 - 0.5 - 0 - 0 - - - tab - - - - - - True - create_large_view - 0 - 0 - Mon, 17 Apr 2006 15:44:42 GMT - - - False - True - - - - - - True - label16 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - + create_main_view + 0 + 0 + Mon, 17 Apr 2006 21:46:51 GMT True diff --git a/system/plots.py b/system/plots.py index 3d554e9..9fe6d8b 100644 --- a/system/plots.py +++ b/system/plots.py @@ -10,6 +10,46 @@ from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationT import scipy import logger +class MainView (gtk.Notebook): + def __init__(self): + gtk.Notebook.__init__(self) + self.set_show_tabs(False) + self.set_show_border(False) + + # Add a multiple pane view and a single pane view. + self.small_view = SmallView() + self.small_view.show() + self.large_view = LargeView() + self.large_view.show() + + self.append_page(self.small_view) + self.append_page(self.large_view) + self.set_current_page(0) + + # Set current view to the upper left view. + self.current_view = self.small_view.get_view(0, 0) + self.current_view.mark_active(True) + + def goto_small(self): + if self.get_current_page() == 0: + return None + self.set_current_page(0) + view = self.large_view.remove_child() + self.small_view.return_current(view) + + def goto_large(self): + if self.get_current_page() == 1: + return None + self.set_current_page(1) + view = self.small_view.borrow_current() + self.large_view.set_child(view) + + def show(self): + gtk.Notebook.show(self) + + def insert_view(self, view): + self.small_view.insert_view(view) + class SmallView (gtk.Table): def __init__(self): gtk.Table.__init__(self, 2, 2, True) @@ -21,6 +61,9 @@ class SmallView (gtk.Table): self.active_x = 0 self.active_y = 0 + + self.set_row_spacings(3) + self.set_col_spacings(3) for x in range(self.cols): for y in range(self.rows): @@ -37,10 +80,22 @@ class SmallView (gtk.Table): self.child_views[col][row] = child child.show() + def borrow_current(self): + self.borrowed = self.child_views[self.active_x][self.active_y] + self.remove_child(self.active_x, self.active_y) + return self.borrowed + + def return_current(self, view): + self.set_child(view, self.active_x, self.active_y) + def remove_child(self, col, row): - self.remove(selv.child_views[col, row]) - self.attach(col, row, EmptyView()) + self.remove(self.child_views[col][row]) + self.attach(EmptyView(), col, col+1, row, row+1) + def insert_view(self, child): + if not self.find_child(child): + self.set_child(child, self.active_x, self.active_y) + def show(self): for x in self.child_views: for y in x: @@ -73,6 +128,9 @@ class SmallView (gtk.Table): if loc: self.set_active(loc[0], loc[1]) + def get_view(self, x, y): + return self.child_views[x][y] + class LargeView (gtk.Frame): def __init__(self): gtk.Frame.__init__(self) @@ -80,7 +138,11 @@ class LargeView (gtk.Frame): self.add(self.child_view) def set_child(self, child): - pass + self.remove(self.child_view) + self.child_view.hide() + self.add(child) + self.child_view = child + child.show() def hide(self): self.child_view.hide() @@ -90,6 +152,12 @@ class LargeView (gtk.Frame): self.child_view.show() gtk.Frame.show(self) + def remove_child(self): + child = self.child_view + child.hide() + self.remove(child) + return child + class Plot (gtk.Frame): def __init__(self): @@ -108,7 +176,7 @@ class Plot (gtk.Frame): if active: self.set_shadow_type(gtk.SHADOW_IN) else: - self.set_shadow_type(gtk.SHADOW_ETCHED_IN) + self.set_shadow_type(gtk.SHADOW_OUT) class EmptyView (Plot): def __init__(self):