Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Please bear with me as I'm a newcomer to Linux. I've been writing GUI programs in REALbasic on a Mac for several years. I'm trying to learn Python and I want to write GUI apps for Linux (primarily Ubuntu and Mint since they are the distros I have access to and they seem to be the most popular). I basically have three questions:

  1. Are there any significant differences between GTK and QT
  2. I've toyed with quickly and Glade on Ubuntu but I understand that they are based on GTK 2 and this is now obsolete. Is that correct?
  3. Are there any all-in-one editors that let me design a GUI and then add Python code to it? (for instance, add a button to a window in the editor, double click the button and then add the Python code that is to execute when the button is pressed)

Sorry if these are really dumb questions but I want to start learning the 'right' tools from the start.

share|improve this question
2  
I don't have time right now to answer your questions, but I can clarify something. Glade used to be both a library, a format for a UI definition file and an application to create those .glade files. Now we use GtkBuilder for what the Glade format used to do, and that is built in to GTK. Glade the application lives on as a great tool to make .ui files for GtkBuilder (or simply to test different layouts), and Glade 3.x certainly does do Gtk3 — though not everything is there at this moment. –  Dylan McCall Dec 4 '11 at 21:52
    
That is very helpful. So if I decide to use GTK as my toolkit then I'd use Glade to design the layout and another tool to link my Pyhton code and the UI design - correct? –  Nootrino Dec 5 '11 at 7:15
    
Yep, and that tool is part of GTK, so it's documented over here: developer.gnome.org/gtk3/3.1/GtkBuilder.html I'm linking you to the C documentation because it's pretty detailed, and when you're using PyGObject the only real difference will be the syntax. In Python, the names and stuff will look something like this: valadoc.org/gtk+-3.0/Gtk.Builder.html –  Dylan McCall Dec 5 '11 at 8:32
add comment

4 Answers

up vote 10 down vote accepted

I'll try to answer your questions, without going in crazy directions.

  1. They are significantly different, even though they are both widget libs. Regular GTK+ is based on C, and QT on C++. Although bindings exist for almost every programming languages.

  2. You are fairly correct about GTK2, although there are so many GTK2 applications. I expect GTK2 to be in use for a while, just as GTK1 was. When push comes to shove, GTK2 is deprecated, and if you are starting fresh go GTK3.

  3. Remeber GTK, and QT, are just widget toolkits. For example... Gnome applications, use GTK and also the Gnome-Libs. If you want that, take a look at vala. It is considered simple, the vala compiles source-to-source directly to C, and has full bindings for many programming languages. You might also want to look at Anjuta, just make sure you have the new gtk3 versions. Apparently strait PyGTK only supports GTK2, current last I checked. If you are looking to avoid all Linux DE libs, I would suggest looking at QT. Plain QT is different from KDE applications, which include KDE libs. QT is considered very cross-platform, which is cool if you want to compile for non *nix. If you want to get started with QT + Python, look at PySide (LGPL) or PyQT (GPL). QT has some good GUI builders like qt creator, and qt-designer.

share|improve this answer
    
Thanks for this. Anjuta pretty much looks like what I have been after. I'm going to play around with it a bit. If it's not right then I will look at QT. It strikes me that both GTK and QT achieve the same end result - it's just a matter of preference I guess. –  Nootrino Dec 5 '11 at 7:17
    
Qt is much more than just a widget toolkit. It is an entire framework, replicating large chunks of the STL and Boost. –  scottl Dec 6 '11 at 1:30
    
@scottl, I was not trying to limit QT. While QT is more capable than just widgets, it's in that context it became part of the potential solution. –  TechZilla Dec 8 '11 at 10:53
    
@Nootrino: you have to remember in the FLOSS world, there is often more than one established solution. The reason many people have chosen, one or the other, is based on their C vs, C++ standing. Of course, licence played a bigger part in the past. Regardless other frameworks in many languages exist, you usually agree more with one method. –  TechZilla Dec 8 '11 at 11:00
    
@Nootrino: I'm glad I was able to actually help! –  TechZilla Dec 8 '11 at 11:01
add comment

GTK and Qt are open-source cross-platform User Interface toolkits and development frameworks. These are the two most popular frameworks in use for Linux because they are open-source and give developers a powerful toolkit to design Graphical User Interfaces. GTK is used as the standard toolkit for the GNOME, LXDE and Xfce Desktop Environments while Qt is used for KDE.

If you code in C, then obviously go for GTK+

If you code in C++, go for Qt, otherwise you will ned Gtkmm (a C++ wrapper over GTK+)

If you code in Python, both GTK+ and Qt have bindings for the language: see PyGtk, PyQt and PySide (the one launched by Nokia themselves).

share|improve this answer
    
If you're using Python, PyGTK is deprecated. For new projects you will be much better off using PyGObject (python-gobject in Ubuntu's repository): live.gnome.org/PyGObject PyGObject lets you connect to any library built on GLib (such as GTK) through Python, without any extra layers. You get something very much like PyGTK, but it goes about it quite differently. And, of course, PyGObject is the only way to talk to GTK3 through Python. –  Dylan McCall Dec 4 '11 at 22:00
add comment

In simple words,

Qt-> based on C++

GTK+ -> based on C

share|improve this answer
1  
This is something of an oversimplification, though, considering that GTK+ has bindings for many languages, including C++, and GTK+'s C++ bindings actually use C++ in a way more true to the language and standard library than Qt does (since Qt was developed when C++ was in a considerably less developed stage). –  Eliah Kagan Jul 2 '12 at 0:31
add comment

Qt is mainly used in KDE, and GTK+ in GNOME. So if you want to develop for GNOME, consider GTK+ since the necessary dependencies for GTK+ libraries should already be installed on a GNOME system; the end user will not need to install them. GTK+ development is also benefited by a tool called Glade Interface Designer; if you wish, you can use that to create your user interfaces.

share|improve this answer
3  
QT is a cross platform toolkit it is not only used in KDE, and so is GTK. AND please refrain from writting "txt lik dis"... –  Uri Herrera Dec 4 '11 at 20:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.