Helpful Information
 
 
Category: C Programming
call tcl, tk from C.....or call C from tcl, tk?

hey all....

I have a large C program finished and at the moment it has a simple command line interface.

I need to add a gui if possible and the only possibilitie seems to be tcl/tk.....(this is on UNIX)

to be honest, I don't want to go in and change a lot of the code and the tcl/tk API looks like it's a bit complicated.

Is it possible to call a C program from tcl/tk....anyone know of an easy way of doing this?

thanks, Des

make your c program do anything possible using command-line options.

then make the GUI using Tcl (though there is at least 100 other options to do it ;) )

you can call c programs and get the output in TCL using "[command]".

http://www.arsdigita.com/books/tcl/ will give you a good grounding in Tcl. Tk is of course not covered there as such (it's focused on using tcl in non-gui environments), but Tk really isn't all that difficult. http://resource.tcl.tk/resource/doc/start/ has a list of various online tcl/tk tutorials, the Cookbook and TclTutor look promising. If you know perl, you can use Tk.pm and perl's innate glue capabilities to acheive the same goal (be warned however that you'd still need to know the tao of tk, and it's not as straightfoward to interact with tk in perl as in tcl).

if for some reason you _have_ to ship a static binary, well,
you'd have to change your code to a greater
or lesser extent anyway to bolt on a gui. at that point it's pick your poison as far as what gui lib you want to use... ;)

make your c program do anything possible using command-line options.

then make the GUI using Tcl (though there is at least 100 other options to do it ;) )

you can call c programs and get the output in TCL using "[command]".


hello,
I am himani. I am supposed to open a directory of c programs in tcl/tk.Later I must compile these programs one after another in tcl/tk. Here am using like exec gcc helloworld.c , exec ./a.out helloworld.c .
When am using like above am getting the o/p correctly as "helloworld". But the problem is it's also saying child process exited abnormally. I am not able to understand fork & thread concepts. In this u posted like we can call c and get o/p in tcl using " [command] ".
what is the meaning of it. Does it mean I should use this command as it is in my tcl program ?
Can u explain it in steps specifying commands more clearly taking helloworld.c as argument ? I am supposed to complete it in 1 day. Please reply as soon as possible

Thanks

Quit pulling up 6 year old posts! :chomp:

Don't hijack other people's threads. Don't dig up and hump dead threads. Start your own. If you'd like to refer to an existing thread for good reasons, feel free to do so.










privacy (GDPR)