[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-app-devel
Subject:    Re: Existing GTK+/GNOME Language Bindings
From:       "J.W. Bizzaro" <bizzaro () bc ! edu>
Date:       1999-02-23 22:46:02
[Download RAW message or body]

Tom Jenkins wrote:
> 
> >
> > This binding is in a very good shape and its authors are furiousely working
> > on it right now. Full support for glade is under its way, and GtkAda will
> > also provide a full support for dynamic creation of widgets from a glade's
> > XML file (I've heard that the Python binding has some restricted similar
> > functionnalities, but I've seen nothing for the other bindings).
> >
> Where can I find information on glade support of python (if i'm reading
> this correctly)?

Reply from James Henstridge (PyGTK author):

The GLADE support in python is different from the C glade support. Whereas the C
code generator outputs code that you compile and then run to create the
interface (ie. it has compile time interface generation),  pygtk's GLADE support
is runtime.  To use it, your code should import the pyglade module (well it is
actually a package, but you can treat it as a single module).

From here, you can call the construct function which takes a string argument
giving the XML file to parse:

  wtree = pyglade.construct("/tmp/tester.glade")

This will construct the interface for you.  The function will return an instance
of WidgetTree, which can be used to get the individual widgets defined in the
XML, and connect python functions to the signal handlers defined in the XML. 
The methods you need to know about are these:

  wtree.get_widget("widget_name")
     - get widget with this name
  wtree.connect("signal-name", handler, [extra args, ...])
     - connect to handler to the signals which have signal-name listed as
       their signal handler in the XML file.
  wtree.disconnect("signal-name")
     - disconnect all handlers from this handler name.

The XML parser is a simple one of my own, and will probably fail for any
particularly complicated XML file (I have been meaning to switch over to some
other parser like xmllib.py, but haven't had the time to write a wrapper for
it).

That is about all that you need to know to use GLADE with pygtk (BTW, If you
think runtime interface generation is a good idea and you would like to use it
for your C program, check out the libglade module from the GNOME CVS tree.  It
offers a similar interface for C programs).

James Henstridge.


-- 
         To unsubscribe: mail gtk-app-devel-list-request@redhat.com with 
                       "unsubscribe" as the Subject.

	Mailing list concerns should be mailed to <listmaster@redhat.com>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic