Mercurial > MadButterfly
annotate pyink/FSM_window.py @ 1457:416a18409603
Show an empty document in SVG viewer widget
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sat, 16 Apr 2011 22:25:35 +0800 |
parents | 894a4bf35fe6 |
children | 59b90d7fcf57 |
rev | line source |
---|---|
1456
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
1 import gtk |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
2 import os |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
3 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
4 class FSM_window_base(object): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
5 def __init__(self): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
6 super(FSM_window_base, self).__init__() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
7 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
8 dirname = os.path.dirname(__file__) |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
9 fname = os.path.join(dirname, 'FSM_window.glade') |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
10 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
11 builder = gtk.Builder() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
12 builder.add_from_file(fname) |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
13 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
14 main_win = builder.get_object("FSM_main_win") |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
15 view_box = builder.get_object("view_box") |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
16 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
17 builder.connect_signals(self) |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
18 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
19 self._builder = builder |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
20 self._main_win = main_win |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
21 self._view_box = view_box |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
22 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
23 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
24 def show(self): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
25 self._main_win.show() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
26 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
27 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
28 def hide(self): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
29 self._main_win.hide() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
30 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
31 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
32 def on_start_state_activate(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
33 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
34 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
35 def on_rename_state_activate(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
36 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
37 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
38 def on_remove_state_activate(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
39 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
40 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
41 def on_zoom_out_clicked(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
42 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
43 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
44 def on_zoom_in_clicked(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
45 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
46 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
47 def on_move_state_toggled(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
48 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
49 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
50 def on_add_state_toggled(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
51 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
52 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
53 def on_close_window_activate(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
54 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
55 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
56 def on_FSM_main_win_destroy_event(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
57 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
58 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
59 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
60 class FSM_window(FSM_window_base): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
61 def __init__(self, close_cb, destroy_cb): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
62 super(FSM_window, self).__init__() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
63 |
1457
416a18409603
Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents:
1456
diff
changeset
|
64 self._close_cb = close_cb # callback to close editor window (hide) |
416a18409603
Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents:
1456
diff
changeset
|
65 self._destroy_cb = destroy_cb # callback to destroy editor window |
1456
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
66 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
67 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
68 def set_svg_view(self, view): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
69 self._view_box.add(view) |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
70 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
71 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
72 def on_close_window_activate(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
73 self._close_cb() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
74 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
75 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
76 def on_FSM_main_win_destroy_event(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
77 self._destroy_cb() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
78 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
79 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
80 def on_FSM_main_win_delete_event(self, *args): |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
81 self._destroy_cb() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
82 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
83 pass |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
84 |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
85 if __name__ == '__main__': |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
86 win = FSM_window() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
87 win._main_win.connect('destroy', gtk.main_quit) |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
88 win.show() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
89 gtk.main() |
894a4bf35fe6
Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
90 pass |