Problem adding commands to a Tk interpreter. 
Author Message
 Problem adding commands to a Tk interpreter.

        I'm trying to make a simple Tk application, basically wish
with an extra command or two.
(Tcl7.3/Tk3.whatever) and I'm not getting Tk_Init() to execute
sucessfully.  My compile string:

 gcc -I/usr/sww/tcl/include -I/usr/sww/X11/include test.c -ltcl -ltk
-lm -lX11 -L/usr/sww/tcl/lib -L/usr/sww/X11/lib

        The error I get:
wright [41] a.out
Tcl_AppInit failed: can't read "tk_library": no such variable
% puts $tk_version
can't read "tk_version": no such variable
% wright [42]

        If I define tk_library, it will bail out on tk_version.  If I
define tk_version, it can't find bind!  

My code:

        If I just want Tcl instead of Tk, it works just fine.

#include <stdio.h>
#include <tk.h>

int FooCmd(ClientData clientData, Tcl_Interp *interp,
           int argc, char *argv[]){
  printf("Foo command\n");
  Tcl_SetResult(interp, "Foo triggered", TCL_VOLATILE);

Quote:
}

int BarCmd(ClientData clientData, Tcl_Interp *interp,
           int argc, char *argv[]){
  int i;
  printf("Bar command\n");
  printf("Args are ");
  for(i = 1; i < argc; ++i){
    printf("%s ", argv[i]);
  }
  printf("\n");
  Tcl_SetResult(interp, "Bar triggered", TCL_VOLATILE);

Quote:
}

int Tcl_AppInit(Tcl_Interp *interp){  

  if(Tk_Init(interp) == TCL_ERROR){
        return TCL_ERROR;
  }
  Tcl_CreateCommand(interp, "foo", &FooCmd, (ClientData) NULL, NULL);
  Tcl_CreateCommand(interp, "bar", &BarCmd, (ClientData) NULL, NULL);
  return TCL_OK;

Quote:
}

--
Nicholas C. Weaver             Ash C++ Durbatuluk, ash C++ gimbatul, ash C++

http://www.*-*-*.com/ ~nweaver          -Tolkien (if he programmed C++)
It is a tale, told by an idiot, full of sound and fury, .signifying nothing.


Sun, 19 Apr 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Problems with adding my C commands to Tk...

2. tk commands in a slave interpreter

3. TIP #96: Add [tk caret] Command and Tk_SetCaretPos API

4. How to add Tk commands

5. ANNOUNCE: Tk extension for adding canvas commands (on items)

6. a small Tk extension -- adding a command to define bitmap

7. Problem with adding a new TCL command

8. Info commands does not show extension added commands?

9. tk interpreter problem

10. TK Problem: Adding a text label to a frame border

11. TK Problem: Adding label to frame border

12. Tk 8.3.1 send transmits data in wrong encoding to older Tk interpreters

 

 
Powered by phpBB® Forum Software