Home Home Contact us Contact
home News Projects Tests Files Follow manatlan on Twitter Sign in
Last edition : 2008-10-14 21:11:24.191107


GladeApp is a class to help you to developp Pygtk Application with Glade interface.

It takes the idea behind "tepache/SimpleGladeApp" from Tigrus Writing PyGTK applications in a visual way. (AFAIK, it's not maintain anymore)

Tepache used the "patch/diff mechanism" to generate/update a pygtk class structure from a glade file.(You'd just to modify your GUI with glade, save the glade file, and pass it thru the to update your py file, containing a python class wrapping around your widget)

GladeApp is similar, except you don't have the need to use tepache to update your py file. You just inherit your class from GladeApp. And at runtime, it will warn you from the missing signals. You'll have just to copy/paste them in your code, and implement them. (it's like GladeGen)

The simplest example (using which contains a button, and 2 events):

A python:

import os
from gladeapp import GladeApp

class Window(GladeApp):
    glade=os.path.join(os.path.dirname(__file__), '')

    def init(self):

    def on_button1_clicked(self,*args):
        print "hello"

    def on_window1_delete_event(self, *args):



GladeApp is available on the SVN account of Jbrout.

Download GladeApp

In progress / Future


I'm working on the ability to describe widgets tree in the docstring of the class.

An example:

class MyWindow(GladeApp):
    Window win
            Label jo
                .label="Who are you ?"
                    .label = Name
                entry eName
                gtkEntry eMail
            Button b
    def init(self,m):

    def on_b_clicked(self,*a):

    def on_win_delete_event(self,*args):

f=MyWindow("Qui est tu ?")
print f.loop()

How it works :

In fact, the docstring is converted as a "glade file". The tree of widgets is indented, like python code.

  • line starting with a dot is an property of the parent widget.
  • line starting with a @ is a declaration of a event of the parent widget.
  • otherwise it's a child widget ...

Widgets are not case sensitive (and can start with "Gtk" or not). If a second word is provided it will be used as an "id", otherwise an "unique id" will be build according the type of widget.

The window is created with glade, widgets are provided as attributs of the instance, and signals are autoconnected on method "on _ {widgetId} _ {event} (self,*args)" (if a signal is missing in your class, it warns you at runtime)

It will not replace the use of glade-3 for complex widget ... but I think it's an easy way to code very quickly a simple pygtk window/form.

I think it could be really useful/handly... If you know well the names of gtk widget/event/properties, you can code your gtk-GUI as your code your python, in your favorite editor, without the need to use glade-3 to change/add/modify a glade file. Code and Interface stays together ... It's a real breeze ...

AND BETTER : GladeObj !!

GladeObj give the ability to build its own gtk objects ! It's not dependant from GladeApp, and can be used in a common pygtk app. An example:

class MyHbox(GladeObj):
        Entry ee
        Button bm       # button for decrement "ee"
        Button bp       # button to increment "ee"
    def init(self,v):
    def on_bm_clicked(self,*args): int( ))
    def on_bp_clicked(self,*args): int( ))

a = MyHBox(12)

"a" is now a REAL Gtk.HBox, and can be packed/added to any container !

RSS Python Powered Get Ubuntu
©opyleft 2008-2017 - manatlan