Linux Picture

Linux GUI Application Development for Windows Programmers
How do you get started?
Anthony Barker

December 1, 2002

Moving from windows to linux development you are confronted with a myriad of options. QT vs GTK+? Which language should I use: c/c++/java/perl/tcl/python/ruby or javascript? Should I use a commercial/proprietary layout/rad tool (QT or Kylix) or an open source one? What about Mozilla? My background was primarily in programming Visual Basic and Lotus Notes(Basic, Java, c/c++ api). Where should I start?


Start with what feels right
I knew I liked the python programming language, with its ability to make programming "as simple as possible, but not any simpler" (Einstein). By allowing you to easily manage high-level data structures your mind is freed to work on other issues. Because the layout of the code is an intrinsic part of the language I find that other people's code far easier to read and understand. Removing the compile cycle saves me time on the debugging and testing. Garbage collection is something that I take for granted. By allowing me to choose the best programming style for the job whether it be procedural, functional, object-oriented or a mix I can get the job done more quickly and effectively. Applications can be frozen - to make for easier distribution. Finally, the "batteries included" nature of the python libraries promotes code reuse and speeds development.

However, the programming language should ideally not be your main criteria in gui toolkit selection - so I did a survey of tools available.


Tool Selection
I looked at TK(2), GTK+(3), QT(4), wxWindows(5), MFC, Windows Forms (.NET), Swing (Java), and FOX(6) and came up with the following criteria for tool evaluation.
  1. Nice layout tools (Kylix, QT, GLADE)
  2. Interface - Object Oriented or semi-OO
  3. Maturity of the toolkit
  4. Number and type of widgets
  5. Quality of widgets/controls
  6. Resource consumption & Responsiveness
  7. Cross Platform Support
  8. Licensing
  9. Cross language support

    And added:
  10. Native look-and-feel (often important to users)
  11. Extent of developer community
  12. Documentation
  13. How easy is it to learn
the results

Avoiding Proprietary Solutions
Three or four options flouted to the top. QT and Kylix both offer nice, fairly easy to use RAD environments. However, I have used FoxPro and Lotus Notes - and am quite weary of proprietary solutions(both had Unix client support and then dropped it). Lock-in can happen later on in application use- when you don't even know it or expect it. Software companies can decide to change direction and no longer invest in your tool - and your application either stalls or dies. If you develop an open source app with QT - you are locked in to keeping the code open. Expensive licenses may be required for porting the code to Mac or Windows. Some companies and tools (Java & Notes) limit your right to distribute your code without additional licensing fees.

I like Native look-and-feel
GTK+ & TK felt too clunky for me under windows and I would like the option of running whatever I write in windows or mac. Let's face it - most users are used to using native widget sets and typically evaluate applications on appearance. If you want to stick to Unix style platforms GTK+ & pyGTK are good choices.

Mozilla - XUL
Another option that seemed intriguing is XUL - the xml code that forms the basis for the Mozilla gui.
Benefits include - a cross platform widget set(1) and the ability to install via a browser (.xpi files) or run it directly from a server ( xulplanet has a nice tutorial). I discovered protozilla - which gives a way of running local cgi scripts or using ipc (pipes) - but it seemed unstable. I also found that you can access COM Objects via the IDispatch interface. The code is currently turned off and is not part of any Mozilla build. It is also very green code and not thoroughly tested.

from a mailing list:
>>>>>>>>>>QUOTE>>>>>>>>>>>

I can corroborate your conclusions.

The are some additional drawbacks to XUL that aren't apparent until you have
developed a significant XUL code-base. I spent a year and half developing a
very large, commercial application based on XUL. Initially, XUL seemed to be
a very attractive solution (and I believe that it still is for small
applications). However, the way that the behavior of an XUL application is
mixed with UI layout specification makes it very challenging to maintain
clean, understandable code. Consequently, the level of development effort
was much higher than I had expected.
>>>>>>>>>>>>>END QUOTE>>>>>>>>>>
The instability of mozilla as a development platform that had me put it aside - this could change in the future.


wxWindows
wxWindows is an open source c++ toolkit that acts as a thin wrapper around the native widget sets - GTK+, WIN32, Mac OS, Motif and others. It has interfaces for c++, perl, python & ruby. I like the idea of a widget set(1) that is a thin wrapper around others - thereby protecting you from changes and allowing cross platform development. I initially had problems getting wxPython running under Linux - the python incarnation of wxWindows, but Robin Dunn improved the install for Linux - and it is now available as an easy to install rpm.

wxPython was created by Robin, who took swig, a tool which helps automate the creation of python classes from C or C++ APIs and created wxPython - the python interface to wxWindows. There are also interfaces for Perl & Ruby for those who prefer those languages. Another bonus is the ability to use XML to define the interface (like GTK+, QT, XUL allow). In theory this allows one to separate the description of the display from the logic of the display. Also I might like to programmatically create the display to speed up development. On the downside, although there are lots of example code snippets, available tutorials are far and few between, most of the documentation is targeted at C++ programmers, and the Mac OS X port is not complete.

Finally I like to ask, "What are people smarter than me using?"

Open Source Applications Foundation have decided on using wxPython after a year of thought
GNU Entreprise - are using wxPython as the basis for the client server application
many other organizations are using wxWindows in one form or another

Now which tools should I use for Layout?
wxDesigner:
one of the most complete but is closed source commercialware
Somewhat focused on C++ development
I don't like having to use their editor
outputs xml, python, c++, or perl code
Good, cheap, and stable - developed by one of the wxWindows developers.

wxGlade:
my new favorite - copying the best features of glade. Easy to use and extend.
Not a full rad - more of a screen drawer.
outputs xml, c++ or python code
nice tutorial
Actively developed

PythonCard:
Nice if you want to make simple quick app.
I find this kind of tool causes people to put the business logic in the gui though.
Speeds development by simplifying the event model.
Outputs python code
No option for xml output - but this may be coming soon
Actively Developed

XRC:
Simple xml widget editor

Boa:
IDE
I have heard good things and have played with it a bit - 0.14 is here

GNU Enterprise Form Developer
Not really stable yet - but looks promising.

Choosing a Text Editor
The most popular Python text editors are emacs, vi , and nedit, idle. I use editplus under windows (with idle) and emacs, nedit , and vi under linux. But
many choices are available.

If having the text editor separate from the screen drawing tool is foreign to you - try it - you might like it. If not boa or wxDesigner may be more your style.

For application distribution you can use freeze so the user doesn't need the python interpreter installed. For application distribution there is Inno for windows and rpm or python setup.py for Linux & Mac. In the next segment I will go through a basic tutorial on application development with wxPython

>>> Home

(1) Widgets - called controls in windows are items in your gui - check boxes - text tables etc
(2) TK - From the tkinter toolkit - developed by Sun
(3) GTK+ is the widget set that forms the basis of gnome in Linux
(4) QT is the widget set that forms the basis for kde - it is owned by Trolltech
(5) wxWindows is a widget set that is a layer over native widgets
(6) FOX is another toolkit like wxWindows - popular with Ruby users
Resources
http://www.python.org
http://wxPython.org
http://www.wxWindows.org
http://wxglade.sourceforge.net/
wxDesigner
A list of available frameworks