What is Tkinter?

To understand Tkinter, start with the Tcl programming language. Tcl, which stands for Tool Command Language, is an interpreted programming Language created by John Ousterman in the 1980s when he was at the University of California, Berkeley. He needed a relatively simple programming language for developing engineering tools, so he wrote the explained language in C, which sounded a bit like Python!

Next, he wrote a library in C and Tcl for GUI programming, called Tk. This Tcl/Tk was very popular in the 1980s and 1990s, especially among academics, engineers, and Unx programmers.

And what is Tkinter?

We know Python was first released in 1994 with version 1.1, and the standard library requires libraries for everything from text processing to image processing, as well as the GUI. Guido van Rossum decided that Tk was a ready-made library, and that it was easy to use, so he stopped building another wheel. He wrote an interface in C to call Tk in Python, and packaged Tcl/Tk in the standard library so that Python could implement GUI development functions. And that interface in Python is Tkinter.

Are you like, “How could that be?” In fact, this is also very normal ah, good things, we want to share! Not only does Python call the Tk library directly, but Perl and Haskell GUI libraries also call the Tcl/Tk library.

Is Tkinter worth learning?

With this history of Tcl, Tk, and Tkinter in mind, let’s talk about whether it’s worth learning.

In fact, the choice of any technology depends on whether the characteristics of the technology are suitable for your needs. For Tkinter, its characteristics are roughly as follows:

  • The Python standard library comes with the default

    This Tkinter is, so to speak, Python’s de facto standard GUI library. What are the benefits? Tkinter is available wherever Python is available, so you don’t have to find a third party library to install it separately, thus avoiding a lot of compatibility, versioning, etc., which is more beginner friendly.

  • Tkinter’s API is relatively stable

    Tools developed more than a decade ago still work. Tcl/Tk updates have been slow (basically unchanged) since the mid to late 1990s, with Tcl/Tk8.5 being in use until 2012 when a 8.6 version was released. Slow updates are good, too. You won’t have to write a program that will become unusable in a few years.

  • Tkinter is a pure GUI library

    Tkinter is a pure GUI library, nothing else, and what it really does depends on Python’s other libraries. Unlike PyQT and wxPython, which are all big frameworks, you have to make your own.

  • concise

    This feature can be an advantage: it is suitable for the development of entry-level and small applications, but it also leads to two major problems of Tkinter. One is that the interface is relatively simple. Although Tk8.6 has made some progress, there are still many gaps compared with other frameworks. The other is that the controls provided are more basic, slightly more complex, such as HTML display components to think of another way.

So, when is Tkinter suitable for learning and using?

  • Tkinter is recommended if you are a beginner Python programmer who already knows the basic syntax of Python and wants to do a little hands-on work.

    Because if you keep developing command line applications, it will not be intuitive in many cases, and the sense of achievement will be low, which will not promote the interest of further learning.

    And if this time, directly start the development of Web applications, but also need to understand a bunch of HTML, CSS, JS and other front-end things, more trouble, and even if the development is also on the machine run, really want to deploy to the network and domain name, server a series of problems.

    And after learning Tkinter, you can do a little application immediately, such as local file management widgets, see pictures of the application, decompression widgets… The development of these small applications is really about understanding Python’s methods and libraries for dealing with these problems, and Tkinter just encapsulates a UI. This means that you are actually learning more about Python. Of course, you can optimize these gadgets, make them your own, and even share them with your friends for fun.

  • When is a good time to learn Tkinter for Python programmers with some foundation?

    If you need to write some small tools, as a Python programmer, it is inevitable that you will need some desktop tools to solve some small problems. Learning Tkinter is definitely a low cost, high output choice. For example, I used to test colleagues, some configuration work is very troublesome, and very error-prone, this time with Tkinter to write a configuration tool, it is very convenient.

    Another is that you can write some application prototypes with Tkinter. Most of the time, the requirements of an application are not very clear, you can use Tkinter to write a quick first, put out for discussion, further clarify the requirements. Such as the real demand is clear, and then choose the technical solution according to the demand.

Summary:

Tkinter is suitable for beginners to learn Python, Python programmers to develop some small tools, Python programmers to do prototype applications.

If your goal is to develop commercial desktop applications, Tkinter may not be suitable, so use PyQT or use another language such as C++.


Original author: VincentPing

Content is licensed under a Creative Commons Attribution – Noncommercial – Share alike 4.0 license

Welcome to the planet Python!