Re: [pygtk] GTK_IS_WIDGET on subclass of a widget fails
Christian Becke wrote: Jeffrey Finkelstein schrieb: I'm new to Gtk. I tried to create a subclass of an HBox and add it to a window, but I get a GtkWarning telling me that the assertion `GTK_IS_WIDGET()' fails on the instance of my subclass. For example: ===code=== from gtk import Window, HBox, WINDOW_TOPLEVEL, main class FooBox(HBox): def __init__(self): pass I think you have to call the constructor of the parent object here: def __init__(self): HBox.__init__(self) wouldn't it be better to use super(FooBox,self).__init__() and you have to make your new widget known: import gobject gobject.type_register (FooBox) window = Window(WINDOW_TOPLEVEL) window.add(FooBox()) window.show_all() main() ===/code=== yields a warning at window.add(), namely GtkWarning: gtk_container_add: assertion `GTK_IS_WIDGET (widget)' failed. This causes the widget to not be displayed in the window. I don't really understand why this is; am I missing a method call? Have a look at the gobject tutorial [1]. HTH, Chris [1] http://www.sicem.biz/personal/lgs/docs/gobject-python/gobject-tutorial.html ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/ ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] GTK_IS_WIDGET on subclass of a widget fails
Have a look at this: http://fuhm.net/super-harmful/ ;) On Fri, May 22, 2009 at 3:21 PM, Neil Dugan py...@butterflystitches.com.auwrote: Christian Becke wrote: Jeffrey Finkelstein schrieb: I'm new to Gtk. I tried to create a subclass of an HBox and add it to a window, but I get a GtkWarning telling me that the assertion `GTK_IS_WIDGET()' fails on the instance of my subclass. For example: ===code=== from gtk import Window, HBox, WINDOW_TOPLEVEL, main class FooBox(HBox): def __init__(self): pass I think you have to call the constructor of the parent object here: def __init__(self): HBox.__init__(self) wouldn't it be better to use super(FooBox,self).__init__() and you have to make your new widget known: import gobject gobject.type_register (FooBox) window = Window(WINDOW_TOPLEVEL) window.add(FooBox()) window.show_all() main() ===/code=== yields a warning at window.add(), namely GtkWarning: gtk_container_add: assertion `GTK_IS_WIDGET (widget)' failed. This causes the widget to not be displayed in the window. I don't really understand why this is; am I missing a method call? Have a look at the gobject tutorial [1]. HTH, Chris [1] http://www.sicem.biz/personal/lgs/docs/gobject-python/gobject-tutorial.html ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/ ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/ ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] GTK_IS_WIDGET on subclass of a widget fails
Kelvin Ho wrote: Have a look at this: http://fuhm.net/super-harmful/ ;) Interesting...so what can _I_ do then? This seems like a problem above me... ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] GTK_IS_WIDGET on subclass of a widget fails
Jeffrey Finkelstein a écrit : Kelvin Ho wrote: Have a look at this: http://fuhm.net/super-harmful/ ;) Interesting...so what can _I_ do then? This seems like a problem above me... call HBox.__init__(self), as it was suggested, it will work. ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] GTK_IS_WIDGET on subclass of a widget fails
Jeffrey Finkelstein wrote: from gtk import Window, HBox, WINDOW_TOPLEVEL, main class FooBox(HBox): def __init__(self): pass window = Window(WINDOW_TOPLEVEL) window.add(FooBox()) window.show_all() main() You need to init the HBox in the __init__ method: HBox.__init__(self) -- Jeffrey Barish ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] GTK_IS_WIDGET on subclass of a widget fails
Jeffrey Finkelstein schrieb: I'm new to Gtk. I tried to create a subclass of an HBox and add it to a window, but I get a GtkWarning telling me that the assertion `GTK_IS_WIDGET()' fails on the instance of my subclass. For example: ===code=== from gtk import Window, HBox, WINDOW_TOPLEVEL, main class FooBox(HBox): def __init__(self): pass I think you have to call the constructor of the parent object here: def __init__(self): HBox.__init__(self) and you have to make your new widget known: import gobject gobject.type_register (FooBox) window = Window(WINDOW_TOPLEVEL) window.add(FooBox()) window.show_all() main() ===/code=== yields a warning at window.add(), namely GtkWarning: gtk_container_add: assertion `GTK_IS_WIDGET (widget)' failed. This causes the widget to not be displayed in the window. I don't really understand why this is; am I missing a method call? Have a look at the gobject tutorial [1]. HTH, Chris [1] http://www.sicem.biz/personal/lgs/docs/gobject-python/gobject-tutorial.html ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] GTK_IS_WIDGET on subclass of a widget fails
Christian Becke wrote: I think you have to call the constructor of the parent object here: def __init__(self): HBox.__init__(self) and you have to make your new widget known: import gobject gobject.type_register (FooBox) Thanks Christian, and Jeffrey, that helped. Jeffrey ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/