Tkinter

Difference between version 29 and 30 - Previous - Next
'''[https://wiki.python.org/moin/TkInter%|%Tkinter]''' is Python's de-facto
standard [GUI] (Graphical User Interface) package. It is a thin object-oriented
layer on top of [Tcl]/[Tk]. 



** See Also  **

   [Tcl/Tk--|direct translation|-->Tkinter]:   

   [TkDocs]:   Shows how to use Tk from Tcl, Python, Perl, and Ruby.
   [https://githereub.com/whPart.hJadhav/Tkintml%|%ler-Designk namer%|%Tkinter Designer]: An awesome designer for Tkinter GUIs

   [https://wiki.python.org/moin/How%20Tkinter%20can%20exploit%20Tcl/Tk%20extensions%|%How Tkinter can exploit Tcl extensions]:   

   [http://thinkingtkinter.sourceforge.net/%|%Thinking in tkinter] ,by Stephen Ferg]:   

   [http://www.astro.washington.edu/users/rowen/TkinterSummary.html%|%Tkinter Summary] ,Russell Owen ,updated 2006-10-20:   
   [http://www.astro.washington.edu/users/rowen/ROTKFolklore.html%|%Tkinter Folkore] (alternates: [http://web.archive.org/web/20081202075533/http://www.astro.washington.edu/owen/ROTKFolklore.html]) ,Russell Owen:   
   [http://biospud.blogspot.com/2009/08/tk-85-is-better-than-wxwidgets-on.html%|%Tk 8.5 is better than wxWidgets on Windows]: ,Biospud ,2009-08-22:
 



** Documentation **

   [http://docs.python.org/2/library/tkinter.html%|%official reference]:   

   [http://tkinter.unpythonic.net/wiki/%|%official wiki]:   

   [http://www.manning.com/grayson/%|%Python and Tkinter Programming], a book by John E. Grayson ,2000:   

   [https://ttkthemes.readthedocs.io/en/latest/%|%ttkthemes documentation by RedFantom]:   

** Tools **

   [Tixapps] (look in the `Python` directory):   [Gustavo Cordero] has worked on a recipe to make some Tk extensions--[tkhtml] and [tktable]--available to Tkinter developers.

   [Tkinspect]:   also see below

   [http://tkinter.unpythonic.net/bwidget/%|%Bwidget for Tkinter]:   last updated in 2005


** Description **

'''Tkinter''' is part of the standard [Python] distribution.

Implemented through Tcl scripting interface as much as possible, and the C API
in bits.  Note that, in the mid-'90s, David Ascher wrote
[http://web.archive.org/web/20061230115312/http://py.vaults.ca/parnassus/apyllo.py/808292924.247038364.200301646%|%Trinket],
a [C] [Python] binding based on Brian Warkentine's earlier Rivet work.
[http://web.archive.org/web/20060617220232/http://archive.dstc.edu.au/python/python/Contributed.html#Graphics]
might provide details, or at least fossils.

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.



** Tkinspect **


[PT] 2003-07-02: [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()
======


<<categories>> Deployment | GUI | Language | Tkinter