On Fri, Jun 06, 2003 at 12:41:52PM +0300, Ionutz Borcoman wrote:

> Q: Do I need to parse the glade file in every class ? 

You could do this, or you could pass the XML object around, or you could get
the widgets you need in one place and pass them to where they are needed.  

      xml = gtk.glade.XML(GLADEFILE)
      foo_widget = xml.get_widget('foo')
      baz_object = Baz(foo_widget)
      xml.signal_autoconnect(baz_object)
                        
> With what
> parameters ? How do I get a class for the app1, one for about2 and one
> for window1 ? 

Just use get_widget to get these widgets from the tree by name.  Gtk is not
a framework like Qt; you don't sublcass any framework classes.

> Q: What restrictions do I have to consider when setting the callback
> names in glade ? What is the scope of handler names defined in Glade ?

There is just one namespace, so you do have to be careful to use unique
names for things you want to be unique.

> Can I use the same handler name for different handler in different
> objects ? 

http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq03.001.htp

> Is the  'delete' handler for clicked on button4 different from
> that defined for window1 or are they the same ? 

If you give then the same name, 'delete', the handlers are the same.  The
names aren't qualified in the glade file.

You *can* use the same name for the handler.  Howerver, whatever callback
you connect to the handler will get called when either signal is emitted.
If that's not what you intend, give the handlers unique names (if you give
your widgets unique names, this is the default behavior.) 

> Is the 'delete' handler
> for app1 different from that for 'delete' handler for window1 ?

Ditto.  But, again, by default these will be given different handler names:
'on_app1_delete_event' and 'on_window1_delete_event'.

> Q: Can I turn the notebook1 and notebook2 into custom classes ? How do I
> do that ? 

I think you mean objects rather than classes, right?  (Unless you do want
different behavior for each notebook).

You can't inherit from already existing widget objects, but you can use
aggretation or delegation:

class NotebookController(object):

      def __init__(self, notebook):
          self.notebook = notebook
          ...
          
      def foo(self, bar):
          self.notebook.foo(bar)

notebook1 = NotebookController(xml.get_widget('notebook1'))

> Can I use handlers defined in glade in my custom classes ?

Sure, see the FAQ entry above for one way to do it.

Dave Cook
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to