[Tkinter-discuss] Changing the label of a tix.NoteBook tab

Luke Maurits luke at maurits.id.au
Sun Apr 26 08:27:16 CEST 2009


> Things are a little more complicated though; if you only pass the page name to pageconfigure, without any option,
> you want all options with their current values to be returned, if you pass one option without
> value the current value should be returned, as in Tkinter.Widget.configure().

Ah, of course.  Tk configure methods aren't just setters, they're also two kinds of getter!  A silly oversight on my behalf.

> The Tix way to achieve this seems to be (taken from Tix.PanedWindow.paneconfigure()):
> 
>     def pageconfigure(self, page, cnf={}, **kw):
>         if cnf is None:
>             return _lst2dict(
>                 self.tk.split(
>                 self.tk.call(self._w, 'pageconfigure', page._name)))
>         self.tk.call(self._w, 'pageconfigure', page._name, *self._options(cnf, kw))
> 
> which appears to be broken, though; when I pass only a pagename to it I get None as return value,
> I need to call nb.pageconfigure(pagename, None) to get something returned, which is at least
> unintuitive, and passing an option as in nb.pageconfigure(pagename, 'label') causes an error.
> 
> A better way to implement it might be the typical Tkinter way:
> 
>     def pageconfigure(self, page, cnf={}, **kw):
>         return self._configure(('pageconfigure', page._name), cnf, kw)
> 
> This allows at least partially to query current values, nb.pageconfigure(pagename, 'label')
> returns a tuple ('label', '', '', '', 'foobar'), nb.pageconfigure(pagename) still returns None if
> used without None as second argument.

Thank you very much for taking the time to explain / explore these variations.  It feels like there's certainly some scope for a bit of polish in the Tix implementation, with NoteBook.pageconfigure not exposed and PanedWindow.paneconfigure broken!  Perhaps it is a low priority because, as I understand, with upcomming versions of Tk, and something called Ttk, Tix may become somewhat obselete anyway.

Thanks again for all your input.

Luke


More information about the Tkinter-discuss mailing list