changeset 1475:8c6078c17f2d

Install test data when show FSM_window
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 24 Apr 2011 18:17:36 +0800
parents 697ebfa9dc47
children eddec4543761
files pyink/FSM_window.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/FSM_window.py	Sun Apr 24 17:59:11 2011 +0800
+++ b/pyink/FSM_window.py	Sun Apr 24 18:17:36 2011 +0800
@@ -293,6 +293,7 @@
 
     def _clear_view(self):
         root = self._root()
+        root.setAttribute('inkscape:groupmode', 'layer')
         
         children = [child for child in root.childList()
                     if child.name() == 'svg:g']
@@ -338,6 +339,9 @@
         pass
 
     def on_add_state_toggled(self, *args):
+        pass
+
+    def _install_test_data(self):
         domview = self._domview
         
         view = self._view_widget.view
@@ -354,7 +358,6 @@
         
         print root_node.name()
         print root_node.childList()[-1].name()
-        root_node.setAttribute('inkscape:groupmode', 'layer')
         root_node.appendChild(line_node)
 
         def show_msg(*args, **kws):
@@ -378,8 +381,6 @@
                                                        240, 180,
                                                        260, 180,
                                                        300, 130))
-        self._update_view()
-        
         state = FSM_state('test1')
         state.init(rdoc, domview)
         state._draw_state_real(root_node, 'test1', 40, 100, 50)
@@ -391,6 +392,13 @@
                                               160, 120,
                                               200, 100))
         pass
+
+    def show(self):
+        self._install_test_data()
+        self._install_test_data = lambda: None
+        self._update_view()
+        super(FSM_window, self).show()
+        pass
     pass
 
 if __name__ == '__main__':