1from __future__ import nested_scopes # required in Python 2.1 2import gtk 3 4OK_CANCEL = 0 5CLOSE = 1 6 7class EditorDialog(gtk.GtkDialog): 8 def __init__(self, canvas, object): 9 gtk.GtkDialog.__init__(self) 10 editor = object.getPropertyEditor(canvas) 11 self.set_title("Property editor") 12 self.vbox.pack_start(editor) 13 def addbutton(text, function): 14 b = gtk.GtkButton(text) 15 b.connect("clicked", function) 16 self.action_area.pack_start(b) 17 b.show() 18 def ok(button): 19 if not editor.apply(): 20 return 21 self.hide() 22 self.destroy() 23 def cancel(button): 24 if not editor.cancel(): 25 return 26 self.hide() 27 self.destroy() 28 if editor.buttons == OK_CANCEL: 29 addbutton("OK", ok) 30 addbutton("Cancel", cancel) 31 else: 32 addbutton("Close", ok) 33 # gtk.grab_add(self) # modal 34 self.show() 35