[Tutor] gtk.Notebook error

Alan Gauld alan.gauld at btinternet.com
Tue Jul 14 01:42:46 CEST 2009


"Amit Sethi" <amit.pureenergy at gmail.com> wrote 

> I am having problem with adding pages to gtk.Notebook :

I know nothing about Gtk so I could mbe missing 
something here but....

> Now while creating I do :
> 
> def new_tab(widget,widget_render):
>   
>    notebook.new_tab(widget_render)
> 
>  notebook = SmNotebook()

These 2 lines look suspicious.
First you access a method of notebook then you 
assign a new object to notebook. Is the original object lost? 
Or is it doing something as a side-effect that keeps it around?
It seems to me it would be better to have two separate names 
for the two objects?

>  box.pack_start(notebook)

This will be the new object used here, I assume thats what 
you wanted?

>  box2=gtk.VBox()
>  icons = gtk.STOCK_ABOUT
>  image = gtk.Image()
>  image.set_from_stock(icons, gtk.ICON_SIZE_DIALOG)
>  box2.pack_start(image,False)
>  button.connect("clicked", new_tab,box2)
> 
> when I do this I get  a warning :   smnotebook.py:18: GtkWarning:
> Can't set a parent on widget which has a parent.

Do you get a full stack trace or just that one lline?
It always helps to see the full trace if its there.

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list