Chapter 6. Graphical Interfaces for Ruby
IN THIS CHAPTER
Graphical excellence is often found in simplicity of design and complexity of data.
Edward R. Tufte, The Visual Display of Quantitative Information
There is no denying that we are in the age of the GUI. For as far into the future as we can see, there is going to be some form of graphical interface as the preferred way to interact with a computer.
We don't see the command line going away in the next decade or so; it definitely has its place in the world. But even the old-time hackers (who would rather use cp -R than a drag-and-drop interface) still enjoy a GUI when it is appropriate.
However, there are significant difficulties with programming graphically. The first problem, of course, is designing a meaningful, usable "front end" for a program; in interface design, a picture is not always worth a thousand words. We can't address these issues here; we are not experts in ergonomics, aesthetics, or psychology.
The second obvious problem is that graphical programming is more complex. We have to worry about the sizes, shapes, locations, and behaviors of all the controls that can be displayed on the screen and manipulated with mouse and/or keyboard.
The third difficulty is that various computing subcultures have differing ideas of what a windowing system is and how it should be implemented. The disparity between these systems has to be experienced to be fully appreciated; many a programmer has attempted to produce a "cross-platform" tool only to find that the impedance mismatch between the GUIs was the hardest part to deal with.
We really can't help much with these problems. The most we can do is give a gentle introduction to a few popular GUI systems (as they relate to Ruby) and offer a few hints and observations.
The bulk of this chapter is devoted to Tk, GTK+, and FOX. Whatever your background is, there is a good chance you are asking, "Why wasn't (insert name of favorite GUI) included here?"
There could be several reasons for this. For one thing, we have limited space because this book is not primarily about graphical interfaces. For another, it's possible that your favorite system doesn't have a mature set of Ruby bindings as yetin which case we encourage you to create them. Finally, not all GUI systems are created equal. We've tried to cover the ones that are most important and most mature; the rest we give at most a passing mention.
The Tk package is part of the standard Ruby installation. The other GUI packages mentioned here can be found in the Ruby Application Archive, which can be found on the official Ruby home page (www.ruby-lang.org).