Search code examples
pythonwebkitpygtk

How to add hboxes and vboxes code to notebook tabs in python gtk


I am doing a small RSS news app for ubuntu. I have created a notebook using

notebook=gtk.Notebook()
win.add(notebook)
label1=gtk.Label()
label1.set_text("one")
notebook.append_page(label1,label1)

And I have this codee with hbox,vbox and a scroller.

box1=gtk.VBox()
win.add(box1)
box2=gtk.HBox()
box1.pack_start(box2)
addressbar=gtk.Entry()
box2.pack_start(addressbar)
gobutton=gtk.Button("GO")
box2.pack_start(gobutton)
gobutton.connect('clicked',gob)    
scroller=gtk.ScrolledWindow()
box1.pack_start(scroller)
web=webkit.WebView()
scroller.add(web)

How to add the second code into the notebook tab in the first code?


Solution

  • You just need to put box1 into the current Notebook page instead of putting it into win.

    label1 = gtk.Label("one")
    box1 = gtk.VBox()
    notebook = gtk.Notebook()
    notebook.append_page(box1, label1)
    win.add(notebook)
    
    box2 = gtk.HBox()
    box1.pack_start(box2)
    #etc
    

    BTW, I don't see you calling the .show method on your widgets; I assume you're calling win.show_all once you've created them all.