Writing a Searchable Dictionary with Ruby and wxWidgets

Written By: Nathan Baker

- 29 May 2006 -
















Description: For today's Ruby lesson, we will explore the creation of a simple GUI, and then create an interface allowing us to search a user-created dictionary.

  1. Introduction
  2. Getting started
  3. Gooey
  4. Making it actually do something

Part 1: Introduction

Kids these days. Always with their 'pointers' and 'icons'. It seems like a program has to have a graphical interface, an integrated web browser and an RSS reader before it gets any respect nowadays. Scripting languages were designed to provide a quick way to automate tasks in a command-line environment, but never let it be said that they haven't changed with the times. No, now most scripting languages give you the option to use one of a myriad of GUI libraries. This does sometimes mean that there are a lot of hastily-written, exceptionally slow GUI programs out there, but these languages offer a flexibility and convenience that most of the mainstream languages can only dream of. Ruby is the latest darling son of the scripting world, so let's look at how easy it is to create one of these newfangled 'windows' with it.

Before I start, however, allow me the first of many digressions while I talk about GUI libraries. For Ruby, there are a number of options. Perhaps the most venerable is Tk, with a long history of being integrated with scripting languages. Tk is designed for people who don't care about the minute details of how their application looks. It's great if you just want to slap some widgets on a form and get on with the real task--writing the application--but not so hot if you honestly care about your GUI's appearance and want to control, even down to the pixel, what the user sees. If you want this, wxWidgets is more for you. wxWidgets is also very similar to the approach that Microsoft languages like C#, VB, and C++ with MFC take, so people with that background may be more comfortable with that. Honestly, the reason I chose wx for this app is because I didn't want to have to talk about packing and layout algorithms. Yeah, I'm a bum.

Next >>