FAQ Index - Search - Recent Changes - Everything - Add entry

<< Previous Entry | FAQ Entry 19.9 | Next Entry >>

19.9. In creating a Gnome Applet, how do I use class members for callbacks?

Just create your verbs list like this in your class:
 class MyApplet:
   def __init__(self,applet):
     verbs = [ ( "Properies", self.properties), ("About",self.about) ]
     applet.setup_menu("xml here",verbs,None)
   def properties(self):
     pass # and display properties
   def about(self):
     pass # and display about box.
When called, 'self' will be set properly.

PyGTK FAQ Wizard | PyGTK Homepage | Feedback to faq at pygtk.org