A Beginner's Guide to Using pyGTK and Glade
The entry in the pyGTK FAQ on porting your application from GTK v1 to GTK v2 is becoming more and more complete. However, you should be aware of a few problems you're going to face. Obviously, all of your GtkText widgets need to be replaced with Gtk.TextView widgets. The corresponding code in the GUI also must be changed to accommodate that move. Likewise, any lists or trees you've done in GTK v1 have to be redone. What may come as a surprise is you also need to redo all dialog boxes, remaking them in GTK v2 format, which looks much nicer.
Also, a few syntax changes occurred, such as GDK moving to gtk.gdk and libglade moving to gtk.glade. For the most part, these are simple search and replaces. Use GtkText.insert_defaults instead of GtkTextBuffer.insert_at_cursor() and radiobutton.get_active() instead of radiobutton.active, for example. You can convert your Glade v1 file into a Glade v2 file using the libglade distribution's Python script. This gets you started on your GUI, but you may need to load Glade v2 and do some reconfigurations before porting your code.
Don't forget you can cut and paste from the Glade widget tree. This can make a redesign quick and painless.
Unset any possible positions in the Properties window so your startup doesn't look weird.
If you have a question you think other people might too, add it to the pyGTK FAQ.
The GNOME IRC server has a useful #pygtk channel. I couldn't have written CANVAS without the help of the people on the channel, especially James Henstridge. It's a tribute to the Open Source community that the principal developers often are available to answer newbie questions.
The finished demo code is available from ftp.linuxjournal.com/pub/lj/listings/issue113/6586.tgz.
Dave Aitel is the founder of Immunity, Inc., a New York-based security consulting company. CANVAS is Immunity's penetration testing and exploit development framework, written entirely in Python using pyGTK. More information on Immunity is available at www.immunitysec.com.
- Readers' Choice Awards 2013
- Mars Needs Women
- Linux Kernel News - November 2013
- Sublime Text: One Editor to Rule Them All?
- RSS Feeds
- Raspberry Pi: the Perfect Home Server
- December 2013 Issue of Linux Journal: Readers' Choice
- Tech Tip: Really Simple HTTP Server with Python
- IBM Will Minimize Impact of Future Disasters
- Linux Systems Administrator
- The kernel doesn't really
1 hour 24 min ago
1 hour 55 min ago
1 hour 56 min ago
4 hours 51 sec ago
- This should be very helpful
5 hours 14 min ago
- As much as I share your point
7 hours 34 min ago
- So girls had it better ?
11 hours 6 min ago
- Reply to comment | Linux Journal
11 hours 26 min ago
- why is GNOME 3 in the fifth position at 14.1 %?
16 hours 58 min ago
- Sublime Is Brilliant!
22 hours 1 min ago