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…
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.
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 Reddit – gnocl 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
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…
Any recommendations for me on which library to use? Please leave it in the comments.
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?
Tk is a bit outmoded. Themed Tk (Ttk aka Tile) provides the modern look and feel you’re looking for.
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…).
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.
package require Tk
button .b -text “Click me” -command exit
package require Tk 8.5
ttk::button .b -text “Click me” -command exit
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: http://wiki.tcl.tk
The community is helpful.