Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C + Tk

2 views
Skip to first unread message

A Maye

unread,
Jan 11, 1994, 10:11:42 AM1/11/94
to

When I compile the following code, and the run it with the tk script below,
I get the two radiobuttons displayed, but they don't do anything. They can't
even be 'pushed'. It seems as if the buttons have had their default bindings
overwritten. As anyone any idea why this is?

I want to be able to run my tk scripts in this way, so my C program controls
what is happening:- ie. the user clicks on a button, and my C program does
something. I don't want to create my own C commands to be registered with
the tcl interpreter. Is this possible? I'm a novice using tcl/tk and am
very stuck.

Thanks.

Andrew.

C Program :-
------------

#include <stdio.h>
#include <stdlib.h>
#include "/home/csirisa_a/staff/xtools/include/tcl.h"
#include "/home/csirisa_a/staff/xtools/include/tk.h"

main (int argc, char *argv[])
{
Tcl_Interp *interp;
int i,code;
Tk_Window w;
char a;

if (argc!=2) {
printf("Wrong # args: \n");
exit(1);
}

interp = Tcl_CreateInterp();
w = Tk_CreateMainWindow(interp,":0",".");
Tcl_VarEval(interp,"wm withdraw .");


code = Tcl_EvalFile(interp, argv[1]);
if (*interp->result != 0) {
printf(interp->result); printf("\n");
}

if(code != TCL_OK) {
exit(1);
}

Tk_MainLoop();
}

Tk Script :-
------------


toplevel .andrew


# build widget .andrew.frame1
frame .andrew.frame1 \
-borderwidth {2} \
-relief {groove}


# build widget .andrew.frame1.radiobutton0
radiobutton .andrew.frame1.radiobutton0 \
-text {Button 0} \
-value {0} \
-variable {V}

# build widget .andrew.frame1.radiobutton1
radiobutton .andrew.frame1.radiobutton1 \
-text {Button 1} \
-value {1} \
-variable {V}

pack append .andrew.frame1 \
.andrew.frame1.radiobutton1 {top} \
.andrew.frame1.radiobutton0 {top}

pack .andrew.frame1 -side top

Sami-Jaakko Tikka

unread,
Jan 22, 1994, 10:04:42 AM1/22/94
to
In article <1994Jan11.1...@gps.leeds.ac.uk>, cs...@scs.leeds.ac.uk
(A Maye) wrote:

> When I compile the following code, and the run it with the tk script below,
> I get the two radiobuttons displayed, but they don't do anything. They can't
> even be 'pushed'. It seems as if the buttons have had their default bindings
> overwritten. As anyone any idea why this is?

I think you should call Tcl_Init and Tk_Init. My program does similar
things and after calling Tcl_Init and Tk_Init things start to work.
--
<A HREF=http://www.cs.hut.fi/~sti/> My home page </A>
HUT/IIA; I don't speak for my employer.

0 new messages