Version 15 of Tkinter

Updated 2004-11-29 17:58:48

Python binding of Tk. It boasts its own Wiki [L1 ].

http://www.python.org/topics/tkinter/

Part of the standard Python distribution. Documented in the Grayson and Lundh books:

http://www.manning.com/getpage.html?project=grayson&filename=Source.html

See the Python Library Reference manual: http://www.python.org/doc/current/lib/tkinter.html

Implemented through Tcl scripting interface as much as possible, and the C API in bits. Note that, in the mid-'90s, David Ascher based a C-based Python binding on Brian Warkentine's earlier Rivet work. Searches for Trinket under [L2 ] and [L3 ] might provide details, or at least fossils.


Gustavo Cordero has worked on a recipe to make some Tk extensions--tkhtml and tktable--available to Tkinter developers. These can be found in the Python/ directory of Tixapps.

More on this subject appears in the Python Wiki [L4 ].


The Python Wiki has its own page for Tkinter [L5 ].


PT 2-Jul-03: Tkinspect can be used to examine and manipulate Tkinter applications. Under windows the Python app needs a little help (as send isn't available for Windows). You can send enable a Tkinter application by including the following:

 root.tk.eval('package require dde; dde servername Tkinter')

which sets up the application as a Tcl DDE server. Tkinspect can connect to this now.

In fact, here is a sample application for good measure (modified from some other example):

 from Tkinter import *

 class App:

     def __init__(self, master):

         frame = Frame(master)
         frame.pack()

         self.button = Button(frame, text="Exit", command=frame.quit)
         self.button.pack(side=LEFT)

         self.hi = Button(frame, text="Speak", command=self.say_hi)
         self.hi.pack(side=LEFT)

     def say_hi(self):
         print "Hello, World!"

 root = Tk()
 root.tk.eval('package require dde; dde servername Tkinter')
 app = App(root)
 root.mainloop()

Interesting things to note about Tkinter: the windows all have numeric names (eg: .123456789) and the Python callbacks are created as Tcl commands with numeric names. This means that Tkinspect (unsurprisingly) cannot inspect the Python code used for the callback. You can however manipulate the window properties and the Tcl environment.


The famous BWidget are also available for Tkinter [L6 ]


See also:


[category ??]