Greetings all,

I have a question about changing the label of a tab in a tix.NoteBook widget.  
Suppose I create a NoteBook and insert a tab (or "page", to use the proper Tk 
terminology) like this:

nb = tix.NoteBook(master)
page = nb.add("a_tab",label="Foo")

and later I decide that I want to change the tab label from "Foo" to "Bar".  
How do I go about this?  If I try:

page.config(label="Bar")

I receive the following complaint:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.0/tkinter/__init__.py", line 1193, in configure
    return self._configure('configure', cnf, kw)
  File "/usr/lib/python3.0/tkinter/__init__.py", line 1184, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-label"

I haven't been able to find any examples of the correct way to change a tab 
label *anywhere* on the web.

After reading the class definition for NoteBook in 
/usr/lib/python3.0/tkinter/tix.py, making a guess about the meaning of the 
tk.call method, and looking at this webpage:

http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixNoteBook.htm

I took a stab in the dark and tried the following bit of code:

nb.tk.call(nb._w,"pageconfigure","tab",*nb._options({},{"label":"Bar"}))

and, lo, it worked!  The problem is that I have only the fuzziest understanding 
of *why* it worked and I'm pretty sure that this isn't the way I'm supposed to 
do it.

Have I missed something stupid?  The fact that the "pageconfigure" 
functionality provided by Tk is not exposed through a nice and friendly method 
on the NoteBook class suggests to me that either somebody just plain forgot to 
do it (unlikely) or (more likely) it was deemed unecessary because there is 
some other way to go about it, similar to my page.config attempt but a little 
different.

Any information the list can provide me on this would be appreciated.  If it 
helps, my Tk version is 8.5.6, my Python version is 3.0.1, and my Linux kernel 
version is 2.6.26.

Thanks,
Luke
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to