Tk Verses Gtk(And Python verses Tcl)

Back when I was using Windows, I searched for some language that would let me create GUI application. I knew C++ – but creating a GUI using C++ was very, very hard. After some searching I found Tcl/Tk – it was perfect. I liked Tk so much that I used it to create GUI in perl programs. And in Ruby. And in Python. I even wrote tutorials for Tcl/Tk and Perl/Tk. Then I discovered Linux. initially I was glad that I did not choose VB – that would mean that I have to throw away all my custom programs. But since I used open languages like Tcl, Perl, Ruby etc, they will run on Linux as well.

But when I actually ran the programs in Linux, I got the shock of a lifetime. The applications I created looked bad – really bad…

TK Screenshot - Ugly

I still use many Tk programs – but because of the looks issue, I decided to stop using Tk for my new programs. So I decided to try GTK. I even created a small application using PyGTK(my first) to view the harddisk space usage in Linux – Frees.

Frees Screenshot

It was a very simple application – all I had to do is run the ‘df’ command, parse its output, and display a small table using that data. I was expecting around 100, 150 lines of code at the most. But after I created the app, I have 500+ lines of code.

At first, I thought that it was a mistake on my part – I thought that I was not using the best method. But then I came across an article in Redditgnocl or PyGtk?.

PyGtk is still the most recommended binding for Gtk. A lot of programs in Linux is written using PyGtk. So naturally there are a few advantages for using it…

  • It will be the more ‘road-tested’ binding.
  • Many system will have it installed by default.
  • Bigger community – so…
    • more support
    • more examples
    • more tutorials
    • etc.

One the other hand, I have to write more code.


If it is a private script – only useful for myself, then I will use Tcl/Tk or Gnometcl. If the script could be distributed, like Frees, then I will use Python GTK.

What about the other options…

  • wxWidgets
  • PyQT
  • Ruby/GTK
  • Perl/GTK

Any recommendations for me on which library to use? Please leave it in the comments.

About Binny V A 102 Articles
Freelance Web Developer on the LAMP Platform. Maintains a blogs Other sites include Bin-Co and OpenJS


  1. how do we do runtime allocation of arrays?
    or while parsing a file if i come across “[Default]” i need to use whatever is in the square bracket as my arry name and the cintents below it should be stored as the values in the array?

  2. I wonder if your count of 500+ lines of code is including all the code to “create” the GUI. If so I’d like to see your code because there is no way that should take 500 lines of code. Also with the more recent ability of GTK to load XML files with UI definitions you don’t have to worry about all the hard coded GUI instantiation code.

    I’ve tried both Tk and GTK in Python and my biggest beef so far is that I’ve learned that even recent version of GTK do not use native dialogs for things like opening files on Windows, where as Tk seem to be getting better and better at matching the OS it is running on. The GTK file open dialog is horrible. Also I think that Tk is getting better in general at having the widgets look like the standard widgets of the OS that you are running on (Windows, Mac, etc…).

  3. Tcl is only ugly if you use the *old* Tk.

    If you use the new themed widgets under the namespace ttk:: they’ll look beautiful.

    Old Tk:
    package require Tk
    button .b -text “Click me” -command exit
    pack .b

    New Tk:
    package require Tk 8.5
    ttk::button .b -text “Click me” -command exit
    pack .b

    And yes, Tcl/Tk is the easiest way to create GUIs. The code above in other toolkits would be like 10 lines or more and you’d probably need an IDE with GUI builder instead of just a text editor.

    Check out the wiki:
    The community is helpful.

4 Trackbacks / Pingbacks

  1. Linux-Benutzung » Re: Auf dem Desktop-Markt hat Linux nichts zu suchen ! Die Linux-Lemminge … - Konsortium will Linux auf die Desktops b…
  2. Python Hello Script » Bin-Blog
  3. Hello Script for Tcl » Bin-Blog
  4. My Windows/DOS Applications | Bin-Blog

Leave a Reply

Your email address will not be published.