[pygtk] Couple of easy questions
Micah Carrick
email at micahcarrick.com
Thu Dec 27 12:11:55 WST 2007
I'm an experienced GTK+ developer using C, however, I'm dinking around
with Python for a new tutorial I'm writing. Took me all of 2 minutes to
figure out how to get my glade file up and properly terminating. :)
Couple of questions...
1. When using gtk.Builder (or glade), in C we use g_object_unref() on
the builder object to free memory when we've moved references to the
widgets we need into variables (don't need the XML sitting around).
Obviously python will handle memory for me, however, do I need to set
the variable to None or something so it knows I'm done with it?
Example:
self.builder = gtk.Builder()
self.builder.add_from_file("ui.xml")
self.window = self.builder.get_object("window")
dic = { "on_window_destroy" : gtk.main_quit }
self.builder.connect_signals(dic)
# I'm done with the builder... is it cleaned up automatically?
2. What's the difference between importing pygtk and just gtk? Is that a
distribution difference? Just 'import gtk' works for me... but I need
this code to be nice and universal.
3. I was looking at some PyGTK projects and noticed some have everything
all in one .py file. Is it common convention to put everything into a
single file, put each class into it's own file, or does it vary from
programmer to programmer?
--
- Micah Carrick
Developer - http://www.micahcarrick.com
GTK+ Forums - http://www.gtkforums.com
More information about the pygtk
mailing list