Integrate Tile into Tkinter

Jeremy Bowers jerf at jerf.org
Wed Oct 20 02:18:45 EDT 2004


On Tue, 19 Oct 2004 23:09:50 -0400, Kevin Walzer wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Are there any plans to integrate the Tile extension from Tk into
> Tkinter? This theming extension allows native look and feel under
> Windows XP and OS X, in particular, and adds a lot of theming
> flexibility to Tk apps. In fact, it would bring Tkinter pretty much in
> line with wxPython in terms of a native "look" on various platforms,
> though wx still has a larger set of core widgets. I've seen only a
> little discusison about Tile in Python circles, but it's one of the most
> important advances going on with Tcl/Tk these days. Anyway, I'm just
> curious, as I have some experience with Tcl/Tk and am learning Python.

Hey, thanks for the pointer. I've been waiting for this for a while, but
not moving in the "Tk circles" I didn't know how close it was to done.

Assuming you've installed Tile such that Tk can find it, try this:

--------------

from Tkinter import *

root = Tk()
root.tk.call('package', 'require', 'tile')
root.tk.call('namespace', 'import', '-force', 'ttk::*')
root.tk.call('tile::setTheme', 'alt')
v = IntVar()
Radiobutton(root, text="Hello", variable=v, value=1).pack()
Radiobutton(root, text="There", variable=v, value=2).pack()

root.mainloop()


--------------

By no means is this a good program in any sense of the term; in particular
I don't know if the "root.tk.call"s can be written more concisely and
the forced import looks dangerous. But at least on my system, that works
as expected and at least demonstrates that you can reach tile from
Tkinter with no need to wait for someone.

(That is *so* going into my Tk programs.)



More information about the Python-list mailing list