An Introduction to the IRAF Widget Server

here is a Sample Xgterm window.

The IRAF widget server works by executing a "GUI file" downloaded by the client, normally an IRAF application written in SPP and using IRAF GIO (graphics i/o) to interact with the user.

Here is the GUI file ($iraf/lib/scr/xgterm.gui) for the Xgterm application. This is the default GUI when an IRAF graphics program is run without specifying a GUI.

    # XGTERM.GUI -- Default GUI for Xgterm, providing a standard
    # graphics terminal emulation.

    reset-server
    appInitialize xgterm Xgterm {
	Xgterm.objects:               toplevel Gterm gterm
	Xgterm*geometry:              640x480
	Xgterm*allowShellResize:      true
    }
    createObjects
    send gterm setGterm
    activate
Here is the IRAF widget server version of the traditional "hello, world" application.

This is the GUI file for the hello world task.

    # HELLO.GUI -- Graphics user interface for the "hello world"
    # demo task.

    reset-server
    appInitialize hello Hello {
    !
    ! Application defaults for the hello world program.
    !

    Hello*objects:\
	toplevel               Form            helloForm\
	helloForm              Label           helloLabel\
	helloForm              Command         quitButton

    Hello*helloForm*background:              bisque
    Hello*helloForm*helloLabel.label:        Hello, world!
    Hello*helloForm*quitButton.fromHoriz:    helloLabel
    Hello*helloForm*quitButton.label:        Quit
    }

    createObjects
    proc quit {widget} { send client gkey q; deactivate unmap }
    send quitButton addCallback quit
    activate

This is the corresponding IRAF program.

    # HELLO -- Prototype widget server version of traditional hello
    # world task.

    procedure t_hello()

    pointer gp
    real    x, y
    int     wcs, key
    char    strval[SZ_LINE]
    char    device[SZ_FNAME]
    char    uifname[SZ_FNAME]
    int     clgcur()
    pointer gopenui()

    begin
	    call clgstr ("device", device, SZ_FNAME)
	    call clgstr ("uifname", uifname, SZ_FNAME)

	    gp = gopenui (device, NEW_FILE, uifname, STDGRAPH)
	    while (clgcur ("coords", x, y, wcs, key, strval) != EOF)
		if (key == 'q' || key == 'Q')
	            break
	    call gclose (gp)
    end

Finally, here is a mockup of a control window GUI for an image browse application, demonstrating what a more complex GUI might look like. The full application has a second window containing a gterm-image widget which is used for image display.

All of these examples were generated by executing actual IRAF GUI tasks using the prototype widget server (xgterm).