Mercurial > MadButterfly
annotate inkscape/MB_Frame.py @ 236:55f86e2f8d40
Modify the format according to the new design.
author | wycc |
---|---|
date | Sat, 27 Dec 2008 10:18:33 +0800 |
parents | 889cdc5f23c5 |
children | db7f22ecd3ad |
rev | line source |
---|---|
233 | 1 #!/usr/bin/python |
2 import inkex | |
3 import pygtk | |
4 import gtk | |
5 from copy import deepcopy | |
6 from lxml import etree | |
7 import random | |
8 | |
236 | 9 # Please refer to http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention for the designed document. |
233 | 10 |
11 | |
12 # Algorithm: | |
13 # | |
14 # We will parse the first two level of the SVG DOM. collect a table of layer and scene. | |
15 # 1. Collect the layer table which will be displayed as the first column of the grid. | |
16 # 2. Get the maximum scene number. This will decide the size of the grid. | |
17 # 3. When F6 is pressed, we will check if this scene has been defined. This can be done by scan all second level group and check if the current scene number is within the | |
18 # range specified by scene field. The function IsSceneDefined(scene) can be used for this purpose. | |
19 # 4. If this is a new scene, we will append a new group which duplication the content of the last scene in the same group. The scene field will contain the number from the | |
20 # last scene number of the last scene to the current scenen number. For example, if the last scene is from 4-7 and the new scene is 10, we will set the scene field as | |
21 # "8-10". | |
22 # 5. If this scene are filled screne, we will split the existing scene into two scenes with the same content. | |
23 | |
24 class Layer: | |
25 def __init__(self,node): | |
26 self.scene = [] | |
27 self.node = node | |
234
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
28 self.nodes=[] |
233 | 29 class Scene: |
30 def __init__(self, node, start,end): | |
31 self.node = node | |
32 self.start = int(start) | |
33 self.end = int(end) | |
34 | |
35 | |
36 class MBScene(inkex.Effect): | |
37 def confirm(self,msg): | |
38 vbox = gtk.VBox() | |
39 vbox.pack_start(gtk.Label(msg)) | |
40 self.button = gtk.Button('OK') | |
41 vbox.pack_start(self.button) | |
42 self.button.connect("clicked", self.onQuit) | |
43 self.window.add(vbox) | |
44 def dumpattr(self,n): | |
45 s = "" | |
46 for a,v in n.attrib.items(): | |
47 s = s + ("%s=%s" % (a,v)) | |
48 return s | |
49 | |
50 def dump(self,node,l=0): | |
51 print " " * l*2,"<", node.tag, self.dumpattr(node),">" | |
52 for n in node: | |
53 self.dump(n,l+1) | |
54 print " " * l * 2,"/>" | |
236 | 55 def parseMetadata(self,node): |
56 for n in node: | |
57 if n.tag == '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scenes': | |
58 self.scenemap={} | |
59 cur = int(n.get("current")) | |
60 self.current = cur | |
61 | |
62 for s in n: | |
63 if s.tag == '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scene': | |
64 try: | |
65 start = int(s.get("start")) | |
66 except: | |
67 continue | |
68 try: | |
69 end = s.get("end") | |
70 if end == None: | |
71 end = start | |
72 except: | |
73 end = start | |
74 link = s.get("ref") | |
75 self.scenemap[link] = [int(start),int(end)] | |
76 if cur >= start and cur <= end: | |
77 self.currentscene = link | |
78 | |
79 pass | |
80 pass | |
81 pass | |
82 pass | |
83 | |
84 | |
233 | 85 |
86 def parseScene(self): | |
234
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
87 """ |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
88 In this function, we will collect all items for the current scene and then relocate them back to the appropriate scene object. |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
89 """ |
233 | 90 self.layer = [] |
234
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
91 for node in self.document.getroot(): |
236 | 92 if node.tag == '{http://www.w3.org/2000/svg}metadata': |
93 self.parseMetadata(node) | |
94 elif node.tag == '{http://www.w3.org/2000/svg}g': | |
95 oldscene = None | |
233 | 96 #print layer.attrib.get("id") |
234
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
97 lyobj = Layer(node) |
233 | 98 self.layer.append(lyobj) |
236 | 99 lyobj.current_scene = [] |
234
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
100 for scene in node: |
233 | 101 if scene.tag == '{http://www.w3.org/2000/svg}g': |
236 | 102 try: |
103 scmap = self.scenemap[scene.get("id")] | |
104 if scmap == None: | |
105 lyobj.current_scene.append(scene) | |
106 continue | |
107 if self.current <= scmap[1] and self.current >= scmap[0]: | |
108 oldscene = scene | |
109 except: | |
110 lyobj.current_scene.append(scene) | |
234
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
111 continue |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
112 |
236 | 113 lyobj.scene.append(Scene(scene,scmap[0],scmap[1])) |
234
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
114 else: |
236 | 115 lyobj.current_scene.append(scene) |
116 pass | |
117 pass | |
118 | |
119 if oldscene != None: | |
120 # Put the objects back to the current scene | |
121 for o in lyobj.current_scene: | |
122 #print o.tag | |
123 oldscene.append(o) | |
234
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
124 pass |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
125 pass |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
126 pass |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
127 pass |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
128 |
233 | 129 self.collectID() |
130 #self.dumpID() | |
131 def collectID(self): | |
132 self.ID = {} | |
133 root = self.document.getroot() | |
134 for n in root: | |
135 self.collectID_recursive(n) | |
136 def collectID_recursive(self,node): | |
137 self.ID[node.get("id")] = 1 | |
138 for n in node: | |
139 self.collectID_recursive(n) | |
140 def newID(self): | |
141 while True: | |
142 n = 's%d' % int(random.random()*10000) | |
143 #print "try %s" % n | |
144 if self.ID.has_key(n) == False: | |
145 return n | |
146 def dumpID(self): | |
147 for a,v in self.ID.items(): | |
148 print a | |
149 | |
150 | |
151 def getLayer(self, layer): | |
152 for l in self.layer: | |
153 if l.node.attrib.get("id") == layer: | |
154 return l | |
155 return None | |
156 | |
157 | |
158 def insertKeyScene(self): | |
159 """ | |
160 Insert a new key scene into the stage. If the nth is always a key scene, we will return without changing anything. | |
161 If the nth is a filled scene, we will break the original scene into two parts. If the nth is out of any scene, we will | |
162 append a new scene. | |
163 | |
164 """ | |
165 nth = self.last_cell.nScene | |
166 layer = self.getLayer(self.last_cell.layer) | |
167 x = self.last_cell.nScene | |
168 y = self.last_cell.nLayer | |
169 if layer == None: return | |
170 for i in range(0,len(layer.scene)): | |
171 s = layer.scene[i] | |
172 if nth >= s.start and nth <= s.end: | |
173 if nth == s.start: return | |
174 newscene = Scene(deepcopy(s.node),nth,s.end) | |
175 newscene.node.set("id", self.newID()) | |
176 layer.scene.insert(i+1,newscene) | |
177 layer.scene[i].end = nth-1 | |
178 btn = self.newCell('start.png') | |
179 btn.nScene = nth | |
180 btn.layer = layer | |
181 btn.nLayer = y | |
182 self.grid.remove(self.last_cell) | |
183 self.grid.attach(btn, x,x+1,y,y+1,0,0,0,0) | |
184 return | |
185 if len(layer.scene) > 0: | |
236 | 186 last = nth |
187 lastscene = None | |
188 for s in layer.scene: | |
189 if s.end < nth and last < s.end: | |
190 last = s.end | |
191 lastscene = s | |
192 for x in range(last+1, nth): | |
233 | 193 btn = self.newCell('fill.png') |
194 btn.nScene = x | |
236 | 195 btn.layer = layer.node.get('id') |
233 | 196 btn.nLayer = y |
197 self.grid.attach(btn, x, x+1, y , y+1,0,0,0,0) | |
236 | 198 if lastscene == None: |
199 node = etree.Element('{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scene') | |
200 node.set("id", self.newID()) | |
201 newscene = Scene(node,nth,nth) | |
202 else: | |
203 lastscene.end = nth-1 | |
204 newscene = Scene(deepcopy(lastscene.node),nth,nth) | |
205 newscene.node.set("id",self.newID()) | |
233 | 206 layer.scene.append(newscene) |
207 btn = self.newCell('start.png') | |
208 x = self.last_cell.nScene | |
209 y = self.last_cell.nLayer | |
210 btn.nScene = nth | |
236 | 211 btn.layer = layer.node.get('id') |
212 btn.nLayer = y | |
213 self.grid.attach(btn, x, x+1, y, y+1,0,0,0,0) | |
214 else: | |
215 # This is the first scene in the layer | |
216 node = etree.Element('{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scene') | |
217 node.set("id", self.newID()) | |
218 newscene = Scene(node,nth,nth) | |
219 layer.scene.append(newscene) | |
220 btn = self.newCell('start.png') | |
221 btn.nScene = nth | |
233 | 222 btn.layer = layer |
223 btn.nLayer = y | |
224 self.grid.attach(btn, x, x+1, y, y+1,0,0,0,0) | |
225 | |
226 | |
236 | 227 |
228 | |
233 | 229 def removeKeyScene(self): |
230 nth = self.last_cell.nScene | |
236 | 231 try: |
232 layer = self.getLayer(self.last_cell.layer.node.get('id')) | |
233 except: | |
234 return | |
233 | 235 x = self.last_cell.nScene |
236 y = self.last_cell.nLayer | |
237 for i in range(0,len(layer.scene)): | |
238 s = layer.scene[i] | |
239 if nth == s.start: | |
236 | 240 if i == 0: |
241 for j in range(s.start,s.end+1): | |
242 btn = self.newCell('empty.png') | |
243 btn.nScene = nth | |
244 btn.layer = layer | |
245 btn.nLayer = y | |
246 self.grid.attach(btn, j,j+1,y,y+1,0,0,0,0) | |
247 layer.scene.remove(s) | |
248 else: | |
249 if s.start == layer.scene[i-1].end+1: | |
250 # If the start of the delete scene segment is the end of the last scene segmenet, convert all scenes in the deleted | |
251 # scene segmenet to the last one | |
252 layer.scene[i-1].end = s.end | |
253 layer.scene.remove(s) | |
254 btn = self.newCell('fill.png') | |
255 | |
256 btn.nScene = nth | |
257 btn.layer = layer | |
258 btn.nLayer = y | |
259 self.grid.attach(btn, x,x+1,y,y+1,0,0,0,0) | |
260 else: | |
261 # Convert all scenes into empty cell | |
262 layer.scene.remove(s) | |
263 for j in range(s.start,s.end+1): | |
264 btn = self.newCell('empty.png') | |
265 btn.nScene = nth | |
266 btn.layer = layer | |
267 btn.nLayer = y | |
268 self.grid.attach(btn, j,j+1,y,y+1,0,0,0,0) | |
269 | |
270 | |
233 | 271 return |
272 | |
273 def extendScene(self,layer,nth): | |
274 layer = self.getLayer(layer) | |
275 if layer == None: return | |
276 for i in range(0,len(layer.scene)-1): | |
277 s = layer.scene[i] | |
278 if nth >= layer.scene[i].start and nth < layer.scene[i+1].start: | |
279 layer.scene[i].end = nth | |
280 if len(layer.scene) > 0: | |
281 layer.scene[len(layer.scene)-1].end = nth | |
282 def setCurrentScene(self,nth): | |
236 | 283 self.current = nth |
233 | 284 for layer in self.layer: |
285 for s in layer.scene: | |
286 if nth >= s.start and nth <= s.end: | |
287 s.node.set("style","") | |
234
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
288 #print "Put the elemenets out" |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
289 layer.nodes = [] |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
290 |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
291 for o in s.node: |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
292 #print " ",o.tag |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
293 layer.nodes.append(o) |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
294 for o in s.node: |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
295 s.node.remove(o) |
233 | 296 else: |
297 s.node.set("style","display:none") | |
298 def generate(self): | |
299 newdoc = deepcopy(self.document) | |
300 root = newdoc.getroot() | |
236 | 301 has_scene = False |
233 | 302 for n in root: |
236 | 303 if n.tag == '{http://www.w3.org/2000/svg}metadata': |
304 for nn in n: | |
305 if nn.tag == '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scenes': | |
306 nn.clear() | |
307 nn.set("current", "%d" % self.current) | |
308 scenes = [] | |
309 for l in self.layer: | |
310 for s in l.scene: | |
311 id = s.node.get("id") | |
312 scene = etree.Element('{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scene') | |
313 scene.set("ref", id) | |
314 if s.start == s.end: | |
315 scene.set("start", "%d" % s.start) | |
316 else: | |
317 scene.set("start", "%d" % s.start) | |
318 scene.set("end", "%d" % s.end) | |
319 | |
320 scenes.append(scene) | |
321 for s in scenes: | |
322 nn.append(s) | |
323 has_scene = True | |
324 if has_scene == False: | |
325 scenes = etree.Element('{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scenes') | |
326 scenes.set("current","%d" % self.current) | |
327 for l in self.layer: | |
328 for s in l.scene: | |
329 scene = etree.Element('{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scene') | |
330 scene.set("ref", s.node.get("id")) | |
331 if s.start == s.end: | |
332 scene.set("start", "%d" % s.start) | |
333 else: | |
334 scene.set("start", "%d" % s.start) | |
335 scene.set("end", "%d" % s.end) | |
336 scenes.append(scene) | |
337 n.append(scenes) | |
233 | 338 if n.tag == '{http://www.w3.org/2000/svg}g': |
339 root.remove(n) | |
340 | |
341 for l in self.layer: | |
342 # Duplicate all attribute of the layer | |
343 lnode = etree.Element("{http://www.w3.org/2000/svg}g") | |
344 for a,v in l.node.attrib.items(): | |
345 lnode.set(a,v) | |
234
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
346 for n in l.nodes: |
889cdc5f23c5
When a scene is selected to0 edit, we copy all of its elements out of the scene so that inkscape can edit it directly. All elements add or delete by the inkspcae will be put back when we switch the scene. The svg2code.py must recognize this structure.
wycc
parents:
233
diff
changeset
|
347 lnode.append(n) |
233 | 348 root.append(lnode) |
349 for s in l.scene: | |
350 snode = etree.Element("{http://www.w3.org/2000/svg}g") | |
351 for a,v in s.node.attrib.items(): | |
352 snode.set(a,v) | |
353 for n in s.node: | |
354 snode.append(deepcopy(n)) | |
355 lnode.append(snode) | |
356 self.document = newdoc | |
357 def newCell(self,file): | |
358 img = gtk.Image() | |
359 img.set_from_file(file) | |
360 btn = gtk.EventBox() | |
361 btn.add(img) | |
362 btn.connect("button_press_event", self.cellSelect) | |
363 btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray")) | |
364 return btn | |
365 def showGrid(self): | |
366 max = 0 | |
367 for layer in self.layer: | |
368 for s in layer.scene: | |
369 if s.end > max: | |
370 max = s.end | |
371 max = 50 | |
372 | |
373 self.grid = gtk.Table(len(self.layer)+1, 50) | |
374 self.scrollwin = gtk.ScrolledWindow() | |
375 self.scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | |
376 self.scrollwin.add_with_viewport(self.grid) | |
377 for i in range(1,max): | |
378 self.grid.attach(gtk.Label('%d'% i), i,i+1,0,1,0,0,0,0) | |
379 for i in range(1,len(self.layer)+1): | |
380 l = self.layer[i-1] | |
381 self.grid.attach(gtk.Label(l.node.get('id')), 0, 1, i, i+1,0,0,10,0) | |
382 for s in l.scene: | |
383 btn = self.newCell('start.png') | |
384 btn.nScene = s.start | |
385 btn.layer = l.node.get('id') | |
386 btn.nLayer = i | |
387 | |
388 self.grid.attach(btn, s.start, s.start+1, i, i+1,0,0,0,0) | |
389 for j in range(s.start+1,s.end+1): | |
390 btn = self.newCell('fill.png') | |
391 self.grid.attach(btn, j, j+1, i , i+1,0,0,0,0) | |
392 btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray")) | |
393 btn.nScene = j | |
394 btn.layer = l.node.get('id') | |
395 btn.nLayer = i | |
396 if len(l.scene) == 0: | |
397 start = 0 | |
398 else: | |
399 start = l.scene[len(l.scene)-1].end | |
400 for j in range(start,max): | |
401 btn = self.newCell('empty.png') | |
402 self.grid.attach(btn, j+1, j+2,i,i+1,0,0,0,0) | |
403 btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray")) | |
404 btn.nScene = j+1 | |
405 btn.layer = l.node.get('id') | |
406 btn.nLayer = i | |
407 self.last_cell = None | |
408 def cellSelect(self, cell, data): | |
409 if self.last_cell: | |
410 self.last_cell.modify_bg(gtk.STATE_NORMAL, self.last_cell.get_colormap().alloc_color("gray")) | |
411 | |
412 self.last_cell = cell | |
413 cell.modify_bg(gtk.STATE_NORMAL, cell.get_colormap().alloc_color("green")) | |
414 | |
415 def doEditScene(self,w): | |
416 self.setCurrentScene(self.last_cell.nScene) | |
417 self.generate() | |
418 gtk.main_quit() | |
419 def doInsertKeyScene(self,w): | |
420 self.insertKeyScene() | |
421 self.grid.show_all() | |
422 self.generate() | |
423 | |
424 def doRemoveScene(self,w): | |
425 self.removeKeyScene() | |
426 self.grid.show_all() | |
427 self.generate() | |
428 def addButtons(self,hbox): | |
429 btn = gtk.Button('Edit') | |
430 btn.connect('clicked', self.doEditScene) | |
431 hbox.pack_start(btn) | |
432 btn = gtk.Button('Insert Key') | |
433 btn.connect('clicked',self.doInsertKeyScene) | |
434 hbox.pack_start(btn) | |
435 btn=gtk.Button('Remove Key') | |
436 btn.connect('clicked', self.doRemoveScene) | |
437 hbox.pack_start(btn) | |
438 def effect(self): | |
439 self.parseScene() | |
440 self.showGrid() | |
441 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) | |
442 self.window.connect("destroy", gtk.main_quit) | |
443 self.window.set_position(gtk.WIN_POS_MOUSE) | |
444 vbox = gtk.VBox() | |
445 self.window.add(vbox) | |
446 vbox.add(self.scrollwin) | |
447 self.vbox = vbox | |
448 hbox=gtk.HBox() | |
449 self.addButtons(hbox) | |
450 vbox.add(hbox) | |
451 self.window.set_size_request(600,200) | |
452 self.window.show_all() | |
453 gtk.main() | |
454 | |
455 | |
456 | |
457 | |
458 | |
459 A = MBScene() | |
460 A.affect() | |
461 | |
462 |