[Tutor] Multiple tabs using tkinter

Zachary Ware zachary.ware+pytut at gmail.com
Tue Feb 7 14:51:19 EST 2017


On Tue, Feb 7, 2017 at 12:59 PM, Alan Gauld via Tutor <tutor at python.org> wrote:
> On 07/02/17 16:41, Zachary Ware wrote:
>
>> Full disclosure, I've never actually used Tix beyond making it build
>> with the rest of CPython on Windows and making sure it actually worked
>> on one of my Linux buildbot workers.  I have only ever seen it as a
>> maintenance headache :)
>
> The beauty of Tix is that it is a full superset of Tkinter
> so you can just put this at the top and it converts your
> code to use Tix:
>
> replace
>
> import Tkinter
>
> with
>
> import Tix as Tkinter

That's just because tix.py does "from tkinter import *".  You can
achieve the same by doing 'from tkinter import *;from tkinter.ttk
import *' (in a separate 'tk.py' if you want everything namespaced in
your code).

> But Tix has over 40 extra widgets including a tabbed notepad,
> balloon, meter, shell and and a very powerful (but undocumented!)
> grid control.

Very little of tkinter is actually documented outside of the official
Tcl/Tk docs, unfortunately.  How does tix.Grid differ from the
standard grid geometry manager (.grid() method on widgets)?

> The most important and commonly used seem to have been
> incorporated into the latest ttk, but not all of them.

Which ones are missing?  I'd recommend raising issues against Tk for
having them added.

>> "Less available" rather than "unavailable" :).  Tix ships with Tcl/Tk
>> with CPython on Windows; on Linux, you'd need to install it separately
>> from Tcl/Tk and python/tkinter.  I honestly don't have a clue how
>> you'd get it on macOS or any other platform that doesn't provide it in
>> a system repository.
>
> It should be easy since its just native Tcl code, there's no C
> involved so far as I know (I haven't checked!). So anywhere Tcl
> runs Tix should work.

There's some Tcl, but mostly C; see
http://svn.python.org/view/external/tix-8.4.3.x/ (particularly the
'generic', 'unix', and 'win' directories).

-- 
Zach


More information about the Tutor mailing list