First: I apologize if this is more of a GTK problem than a PyGtk
problem. I haven't used GTK other than by Python, so it seems
best to start here.
I've bumped up against problems using GtkNotebook, for which I'd
appreciate any help I can get.
I would like to update the contents of a page of a notebook just
before it is displayed. 'page_callback' does just that in a trivial
manner, at least when it's connected to a button callback as shown
by #X# lines. When I try the code below, page_callback falls into
a recursion hole at the line marked #<<<<<<<<<<<<<<<<.
I see two possible solutions: somehow call off the callback when
the page is removed and inserted, or find an entirely different
way to change the contents of what's being displayed on a page.
The problem is that I've found no examples or descriptions of how
either of these might be accomplished.
(I've considered mucking around inside a frame inside the page,
but don't see a clean way to get a handle on the right frame
(or is this what .get_data and .set_data are all about?))
Can anyone give me a hand?
--
Randolph Bentson
[EMAIL PROTECTED]
#!/usr/bin/env python
from gtk import *
import GtkExtra
def page_callback(notebook, crap, page, cnt=[0], *args):
#X#def page_callback(btn, notebook, crap, page, cnt=[0], *args):
cnt[0] = cnt[0] + 1
notebook.remove_page(page)
box = GtkVBox()
box.pack_start(GtkLabel(`cnt[0]`))
box.show_all()
label = GtkLabel("Tab " + str(page))
label.show_all()
notebook.insert_page(box, label, page) #<<<<<<<<<<<<<<<
notebook.set_page(page)
return
win = GtkWindow()
win.connect("destroy", mainquit)
win.connect("delete_event", mainquit)
box1 = GtkVBox(FALSE, 0)
win.add(box1)
button = GtkButton("close")
button.connect("clicked", mainquit)
box1.pack_end(button, expand=FALSE)
notebook = GtkNotebook()
notebook.set_tab_pos(POS_TOP)
box1.pack_start(notebook)
notebook.connect("switch-page", page_callback)
#X#btn = GtkButton("change page 0")
#X#btn.connect('clicked', page_callback, notebook, 'crap', 0)
#X#box1.pack_end(btn)
for i in range(2):
box = GtkVBox()
box.pack_start(GtkLabel("stuff"))
label = GtkLabel("Tab " + str(i))
notebook.append_page(box, label)
win.show_all()
mainloop()