Hi Adam,
Am 26.07.2018 um 03:01 schrieb Adam Jensen:
> I would like to write a very simple "Hello, World" Tk program in C, then
> compile and run it. This is a first step towards extending CLIPS[1] with
> Tk, in much the same way that Python, Ruby, and Perl have a Tk extension.
As Arjen said, using Tk without Tcl is pretty much impossible. Python's
Tkinter (et al.) works this way, they construct Tcl commands (from
strings) and send them to an embedded Tcl interpreter. In C, you use the
functions Tcl_Eval() and Tcl_EvalObj() to run any arbitrary Tcl code.
What you want to do is called "embedding Tcl" in the Tcl world. Most C
programmers here work the other way round, the write C code which is
then loaded into Tcl ("extending Tcl"). That's why you find only little
tutorials for that. Basically, you need to link against the Tcl library
(NOT stub), call TclFindExecutable(), then Tcl_CreateInterp() and then
you get a Tcl_Interp which you can use to run Tcl commands.
The hard part is to do the callbacks - when the user clicks on a button,
you must make sure that code from your language runs.
And BTW, Python's Tkinter did a few things wrong. grid and pack became
methods of the widget objects, which feels very unnatural. It also does
not allow to use ASCII layout like this in Tcl
grid .a .b
grid .c x
So consider to make grid free functions in your wrapper.
Christian