4.2. Add an Exit Button

#!/usr/cogent/bin/phgamma

/*
 * This example adds an exit button to the window created in the last
 * example, illustrating how easy it is to attach a callback.
 *
 * This file is best viewed with a tab width of 4.
 */
 
require_lisp("PhotonWidgets");
PtInit(nil);

window = new(PtWindow);
window.SetDim (300,250);
window.fill_color = PgRGB (240,220,220);

/*
 * Create a PtButton Widget and set resources.
 */
but = new(PtButton);
but.SetPos(130,205);
but.text_string = "Exit";

/*
 * Attach a callback to the button that will exit the program when
 * the button is pressed and released.
 */
PtAttachCallback(but,Pt_CB_ACTIVATE,#exit_program(-1));

PtRealizeWidget(window);
PtMainLoop(); 
		

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.