What is ruby-cdialog?

This is a ruby interface to the cdialog program, supporting all the features and widget types offered by that program.

Why another dialog library?

Thomas Dickey's dialog program (commonly called cdialog) has many more options than the standard dialog program, and supports all the extra widget types introduced by Xdialog. It also supports color, as well as other features.

How does it work?

Options are divided into two types: common options and widget options. Common options affect the operation of the program as a while, while widget options only affect the immediately preceding widget on the command line.

A class called CDialog::Common contains the common options, and provides functions for setting their values.

For each widget type, there is a class (e.g., CDialog::Msgbox) which holds the paramaters and options specified for that options. Each widget class new function takes a CDialog::Common instance as its first parameter; for a chain of widgets to be executed in one cdialog run, only the first widget would have common options, and the rest would be passed nil. An array of widgets can be chained together like this using the class function CDialog::chain(arr).

The cdialog program is executed with the specified options and its standard error output is available to be read (the CDialog::Gauge widget is an exception - it is the only widget that is written to, not read from). This is done by the CDialog::Base#run method.

When the cdialog program exits, the run method returns an array of two elements (a pair): the first is the exit status of the program (which can be influenced by environment variables, see the man page for cdialog(1) for complete details), and the second is the output of the block passed to the method; this will most often be the program's standard error output (its standard output is busy drawing the screen).

A simple example

The code to create a message box saying "Hello, Sailor!" would look like this:

require "cdialog"

c =
c.title("Hello from Ruby").backtitle("Hello from CDialog")

mb =, "Hello Sailor!")

resultarray = {

p resultarray

This program prints the output

[0, []]

when the "OK" button is pressed.

Where can I get this wonderful bit of code?

The ruby-cdialog package is conveniently available from Logo