Version 10 of Tkinter

Updated 2003-07-18 14:36:00

Python binding of Tk.

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, and the C API.


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 [L1 ].


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


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.


See also http://www.astro.washington.edu/owen/TkinterSummary.html

http://www.astro.washington.edu/owen/ROTKFolklore.html

http://www.pythonware.com/library/tkinter/introduction/index.htm


[category ??]