Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

* fluent, system/plots.py: Switching between four and one view now sort of

works. Still a bit buggy, and with messy code.
This commit is contained in:
Einar Ryeng 2006-04-17 22:30:53 +00:00
parent c55a39f7f9
commit a0d2c0d16d
3 changed files with 88 additions and 85 deletions

20
fluent
View File

@ -47,6 +47,11 @@ class FluentApp:
self.log_view.show() self.log_view.show()
return self.log_view 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): def create_small_view(self, str1, str2, int1, int2):
self.small_view = plots.SmallView() self.small_view = plots.SmallView()
self.small_view.show() self.small_view.show()
@ -98,11 +103,8 @@ class FluentApp:
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('small_view') pt = self.widget_tree.get_widget('main_view')
pt.set_child(plot, 1, 1) pt.insert_view(plot)
# 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')
@ -113,12 +115,12 @@ class FluentApp:
logger.log('debug', 'Toggling log window visibility') logger.log('debug', 'Toggling log window visibility')
def on_single_view(self, button): def on_single_view(self, button):
nb = self.widget_tree.get_widget('view_notebook') nb = self.widget_tree.get_widget('main_view')
nb.set_current_page(1) nb.goto_large()
def on_multiple_view(self, button): def on_multiple_view(self, button):
nb = self.widget_tree.get_widget('view_notebook') nb = self.widget_tree.get_widget('main_view')
nb.set_current_page(0) nb.goto_small()
if __name__ == '__main__': if __name__ == '__main__':
gnome.program_init(PROGRAM_NAME, VERSION) gnome.program_init(PROGRAM_NAME, VERSION)

View File

@ -434,79 +434,12 @@
</child> </child>
<child> <child>
<widget class="GtkNotebook" id="view_notebook"> <widget class="Custom" id="main_view">
<property name="visible">True</property> <property name="visible">True</property>
<property name="show_tabs">False</property> <property name="creation_function">create_main_view</property>
<property name="show_border">False</property> <property name="int1">0</property>
<property name="tab_pos">GTK_POS_TOP</property> <property name="int2">0</property>
<property name="scrollable">False</property> <property name="last_modification_time">Mon, 17 Apr 2006 21:46:51 GMT</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

@ -10,6 +10,46 @@ from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationT
import scipy import scipy
import logger 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): class SmallView (gtk.Table):
def __init__(self): def __init__(self):
gtk.Table.__init__(self, 2, 2, True) gtk.Table.__init__(self, 2, 2, True)
@ -21,6 +61,9 @@ class SmallView (gtk.Table):
self.active_x = 0 self.active_x = 0
self.active_y = 0 self.active_y = 0
self.set_row_spacings(3)
self.set_col_spacings(3)
for x in range(self.cols): for x in range(self.cols):
for y in range(self.rows): for y in range(self.rows):
@ -37,10 +80,22 @@ class SmallView (gtk.Table):
self.child_views[col][row] = child self.child_views[col][row] = child
child.show() 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): def remove_child(self, col, row):
self.remove(selv.child_views[col, row]) self.remove(self.child_views[col][row])
self.attach(col, row, EmptyView()) 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): def show(self):
for x in self.child_views: for x in self.child_views:
for y in x: for y in x:
@ -73,6 +128,9 @@ class SmallView (gtk.Table):
if loc: if loc:
self.set_active(loc[0], loc[1]) self.set_active(loc[0], loc[1])
def get_view(self, x, y):
return self.child_views[x][y]
class LargeView (gtk.Frame): class LargeView (gtk.Frame):
def __init__(self): def __init__(self):
gtk.Frame.__init__(self) gtk.Frame.__init__(self)
@ -80,7 +138,11 @@ class LargeView (gtk.Frame):
self.add(self.child_view) self.add(self.child_view)
def set_child(self, child): 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): def hide(self):
self.child_view.hide() self.child_view.hide()
@ -90,6 +152,12 @@ class LargeView (gtk.Frame):
self.child_view.show() self.child_view.show()
gtk.Frame.show(self) gtk.Frame.show(self)
def remove_child(self):
child = self.child_view
child.hide()
self.remove(child)
return child
class Plot (gtk.Frame): class Plot (gtk.Frame):
def __init__(self): def __init__(self):
@ -108,7 +176,7 @@ class Plot (gtk.Frame):
if active: if active:
self.set_shadow_type(gtk.SHADOW_IN) self.set_shadow_type(gtk.SHADOW_IN)
else: else:
self.set_shadow_type(gtk.SHADOW_ETCHED_IN) self.set_shadow_type(gtk.SHADOW_OUT)
class EmptyView (Plot): class EmptyView (Plot):
def __init__(self): def __init__(self):