Mercurial > MadButterfly
comparison pyink/FSM_window.py @ 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 |
comparison
equal
deleted
inserted
replaced
1474:697ebfa9dc47 | 1475:8c6078c17f2d |
---|---|
291 root = doc.root() | 291 root = doc.root() |
292 return root | 292 return root |
293 | 293 |
294 def _clear_view(self): | 294 def _clear_view(self): |
295 root = self._root() | 295 root = self._root() |
296 root.setAttribute('inkscape:groupmode', 'layer') | |
296 | 297 |
297 children = [child for child in root.childList() | 298 children = [child for child in root.childList() |
298 if child.name() == 'svg:g'] | 299 if child.name() == 'svg:g'] |
299 for child in children: | 300 for child in children: |
300 root.removeChild(child) | 301 root.removeChild(child) |
336 def on_FSM_main_win_delete_event(self, *args): | 337 def on_FSM_main_win_delete_event(self, *args): |
337 self._destroy_cb() | 338 self._destroy_cb() |
338 pass | 339 pass |
339 | 340 |
340 def on_add_state_toggled(self, *args): | 341 def on_add_state_toggled(self, *args): |
342 pass | |
343 | |
344 def _install_test_data(self): | |
341 domview = self._domview | 345 domview = self._domview |
342 | 346 |
343 view = self._view_widget.view | 347 view = self._view_widget.view |
344 doc = view.doc() | 348 doc = view.doc() |
345 rdoc = doc.rdoc | 349 rdoc = doc.rdoc |
352 line_node.setAttribute('y2', '100') | 356 line_node.setAttribute('y2', '100') |
353 line_node.setAttribute('style', 'stroke: #000000; stroke-width:2') | 357 line_node.setAttribute('style', 'stroke: #000000; stroke-width:2') |
354 | 358 |
355 print root_node.name() | 359 print root_node.name() |
356 print root_node.childList()[-1].name() | 360 print root_node.childList()[-1].name() |
357 root_node.setAttribute('inkscape:groupmode', 'layer') | |
358 root_node.appendChild(line_node) | 361 root_node.appendChild(line_node) |
359 | 362 |
360 def show_msg(*args, **kws): | 363 def show_msg(*args, **kws): |
361 print 'mouse_event' | 364 print 'mouse_event' |
362 print args | 365 print args |
376 domview.add_transition(state1, 'event1', state2) | 379 domview.add_transition(state1, 'event1', state2) |
377 domview.set_transition_path(state1, 'event1', (200, 150, | 380 domview.set_transition_path(state1, 'event1', (200, 150, |
378 240, 180, | 381 240, 180, |
379 260, 180, | 382 260, 180, |
380 300, 130)) | 383 300, 130)) |
381 self._update_view() | |
382 | |
383 state = FSM_state('test1') | 384 state = FSM_state('test1') |
384 state.init(rdoc, domview) | 385 state.init(rdoc, domview) |
385 state._draw_state_real(root_node, 'test1', 40, 100, 50) | 386 state._draw_state_real(root_node, 'test1', 40, 100, 50) |
386 | 387 |
387 trn = FSM_transition('event1') | 388 trn = FSM_transition('event1') |
389 trn._draw_transition_real(root_node, (100, 100, | 390 trn._draw_transition_real(root_node, (100, 100, |
390 140, 120, | 391 140, 120, |
391 160, 120, | 392 160, 120, |
392 200, 100)) | 393 200, 100)) |
393 pass | 394 pass |
395 | |
396 def show(self): | |
397 self._install_test_data() | |
398 self._install_test_data = lambda: None | |
399 self._update_view() | |
400 super(FSM_window, self).show() | |
401 pass | |
394 pass | 402 pass |
395 | 403 |
396 if __name__ == '__main__': | 404 if __name__ == '__main__': |
397 win = FSM_window() | 405 win = FSM_window() |
398 win._main_win.connect('destroy', gtk.main_quit) | 406 win._main_win.connect('destroy', gtk.main_quit) |