Hi,

I have one doubt regarding libglade.  How is it
creating the widgets from glade file.  It seems like
the widgets are created during creation of GladeXML
object.
  gxml = glade.XML('pathtogladefile')

I am searching for a way to _apply_ glade file to
existing widget (which is already created).  

I will make the above point clearer.  Look at the
following pygtk example, which doesn't use libglade.

class MyWindow(gtk.Window):
    def __init__(self):
        super(MyWindow, self).__init__()
        # any other stuffs like adding widgets
win = MyWindow()
win.show()

The main advantage of this style is `win` is actually
_is_ a widget (a gtk.Window).  So I call win.show()
instead of doing tricks like win.widget.show().  But
is it possible to achieve this advantage, when using
glade file for generating the UI.  NO!  I tried the
following.

class MyWindow2(gtk.Window):
    def __init__(self):
        super(MyWindow, self).__init__()
        self.gladexml = glade.XML('my.glade')
        wind = self.gladexml.get_widget('main_window')
        
Here there is a confusion.  Actually there are _two_
windows in existense.  One is `self` and other is
`wind`.  To avoid this I should _not_ inherit from
gtk.Window.  But this means the advantages of previous
example are lost.  

I think the solution to this problem is libglade
should have a function that takes already created
widget (window?) as id and sets the properties on that
widget, then adding the children that widget.  That
widget is commonly a gtk.Window.  If libglade has such
a function them the above example could be written as
..

class MyWindowGreat(gtk.Window):
    def __init__(self):
        super(MyWindow, self).__init__()
        self.gladexml = glade.XML('my.glade',
existing=self)
        wind = self.gladexml.get_widget('main_window')
        print wind is self # This is prints `True`

The _definition_ of glade.XML.__init__ looks something
like

  (In C)
  GladeXML *
  glade_xml_new(... , GtkWidget *existing, ...)
  {
    ....
    if (existing == NULL){
      existing = gtk_window_new(...)
    }
    ...
  }

  /* just a thought */

  Hopes that clears everything. 

  Thanks.

=====
Sridhar R 
Email: [EMAIL PROTECTED]
WWW:   http://sridhar.has.it

__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
_______________________________________________
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