GUI:-please answer want to learn GUI programming in python , how should i proceed.

Kevin Walzer kw at
Mon Dec 16 15:55:20 CET 2013

On 12/15/13, 5:06 PM, Chris Angelico wrote:

> Yeah, but there's a difference between passing your GUI incantations
> on to a library function (written in C but now just part of a binary
> library) and feeding them to a completely different language
> interpreter. When I write something with PyGTK, I can't, even in
> theory, give it arbitrary C code to execute. From what I understand
> here, that *is* true of Tcl, which means that the Python download
> contains a Python interpreter and a Tcl interpreter. I'm not saying
> that's a bad thing to do, but it is calculated to provoke remark.

Yes, a Tkinter app has both a Python interpreter and an underlying Tcl 
interpreter. Let's be clear about that.

The technical reason for this is that, during Python's early 
development, Tk was the simplest, most powerful and OSS-friendly GUI 
toolkit out there (compared to, let's say, Motif). Its reliance on Tcl 
was a plus because Tcl's C API is exceptionally clean and easy to 
embed/call from other C libraries (that was Tcl's original main focus, 
embedding in C).

Embedding the Tcl interpreter remains a sound decision today. It makes 
it trivial to keep Tkinter updated in sync with Tk updates, since the 
Tcl interpreter does most of the heavy lifting. The recent effort to 
wrap Tk's new themed widgets is a good one: nearly all of the work was 
done at the Python level. Compare this approach to Perl's original one, 
which stripped out Tcl and implemented Tk integration entirely in C. Any 
updates require heavy lifting in C and, in fact, Perl/Tk has not kept up 
with Tk's main line of development (it does not run natively on the Mac, 
for instance).

Calling through Tkinter to Tcl also provides some other conveniences. If 
you're writing a Tkinter app and want to access some platform-specific 
functionality that requires C calls, that may require a library 
extension written against Tcl/Tk's C API (i.e. the Mac's NSServices 
API--that can't be accessed using ctypes because it hooks into the 
window server). Fortunately, Tk is very easy to extend in C--much 
simpler than extending wxWidgets or Qt.

Finally, Tcl is itself a fully-featured, general programming language 
that is a peer to Python both generationally and in terms of its 
capabilities; the main way it lags is in the size of its development 
community. In other words, you are not handing the ball off to a 
90-pound weakling if you need to call into Tcl from Python via Tkinter. ;-)


Kevin Walzer
Code by Kevin/Mobile Code by Kevin

More information about the Python-list mailing list