Attachment "main.c" to
ticket [1038760f]
added by
nirajvdesai
2004-10-02 05:35:28.
/* main.c for event loop testing */
#include <stdio.h>
#include <tk.h>
#include <unistd.h>
/* compile with:
gcc -o tclmodal main.c -ltcl8.4 -ltk8.4
*/
static Tcl_Interp *interp;
int TclIsRunning;
void tkexit(void *d, XEvent *eventPtr)
{
if (eventPtr->type == DestroyNotify) {
Tcl_DeleteInterp(interp);
TclIsRunning = 0;
}
}
int main(int argc, char *argv[])
{
const char *exePath_;
Tcl_FindExecutable(exePath_);
interp = Tcl_CreateInterp();
Tcl_Init(interp);
Tk_Init(interp);
Tk_Window nw;
nw = Tk_MainWindow(interp);
Tk_CreateEventHandler(nw, StructureNotifyMask, tkexit, 0);
Tcl_EvalFile(interp, "modaldlg.tcl");
TclIsRunning = 1;
while (TclIsRunning) {
while (Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT));
printf("Returned from Tcl_DoOneEvent ");
usleep(10);
}
printf("Exiting\n");
return 0;
}