On Mon, Jan 19, 2004 at 11:49:07PM -0800, Sridhar R wrote:
>   No. not multiple, only single.  glade.XML() creates
> the widgets immediately.  My problem is to instruct
> not to create (a particular widget say gtk.Window i.e.
> toplevel in glade file) the widget immediately.  So
> that later I can pass my own widget (here gtk.Window
> instance, a base class instance) to some func in
> libglade so that it assigns properties acc. to glade
> file and return completely designed (with children
> added) window.
>  
> 
>  Again I tried this,
> 
>   class MyWind(gtk.Window):
> 
>    def __new__(cls, *args, **k):
>       xml = glade.XML('file.glade')
>       w = xml.get_widget('toplevel_wind')
>       return w
> 
>     def __init__(self):
>        pass
> 
> 
> But the problem here is self (in __init__) is a base
> class instance.

Well, one way to work around this is to define the gtk.Window in your
code, and have a dummy window defined in Glade that you destroy at
startup:

    class MyWindow(gtk.Window): pass
    
    gladewin = xml.get_widget('fake_toplevel')
    win = MyWindow()
    child = gladewin.get_children()[0]
    child.reparent(win)

However, note that you'll loose keyboard accelerators tied to the fake
toplevel. I've fought (and solved -- in GTK+ 1.2) this issue before; see
http://bugs.async.com.br/show_bug.cgi?id=840 for details.

> Is there any way to convert an base class instance to
> derived class instance???
> (Note: one cannot set the __class__ attr of instances)

Why not? Do you mean any Python instance or just gtk instances? :-)

    >>> class Foo: pass
    ... 
    >>> f = Foo()
    >>> class Bar: pass
    ... 
    >>> f.__class__
    <class __main__.Foo at 0x401c626c>
    >>> f.__class__ = Bar
    >>> f.__class__
    <class __main__.Bar at 0x401c629c>

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331
_______________________________________________
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