23

I’m a C programmer with no desire to deal with C++ tool-kits, and I’m trying to build a simple graphical card game. I’m programming under Linux, but I’d like to have the option of a Windows port. From what I’ve read, my options are GTK+ and Tk.

I’m working through some GTK+ tutorials, and I’ll probably stick with that, but I don’t think I’m giving Tk a fair shot. Trouble is, all the Tk documentation I can find is either for using Tk with {Tcl, Ruby, Perl, Python}, or for embedding a Tcl interpreter into the C program and using Tk that way. Is there an easy(-ish) way to use Tk to build GUIs for a C program without digressing too much into Tcl?

Ideally, is there a tutorial (something along the lines of the TkDocs Tk Tutorial) but using something like the Tk C API?

J. C. Salomon
  • 4,143
  • 2
  • 29
  • 38
  • Three pointers to embedding Tcl into the program to build the GUI with Tk. Good to know, but I was hoping for the plain-C equivalent of [C++/Tk](http://cpptk.sourceforge.net/). Which may simply not exist. Oh, well. – J. C. Salomon Dec 19 '11 at 17:41
  • It's usually harder to do it that way; C is a language that's _superb_ for building low-level components of a system, but it's nice to use a higher-level language to piece the C components together with. (I prefer Tcl for that, but the other ones you listed work well too.) I feel C++/Tk to be a very strange hybrid beast, almost like a mythological monster. :-) – Donal Fellows Dec 20 '11 at 18:55
  • 1
    Yes there is no way to use TK from C only. It assumes a working TCL infrastructure (like strings, hashs etc.). If this is a problem for you are left with GTK (or Win32 API) - but it shouldn't. – Lothar Feb 05 '12 at 07:32

2 Answers2

9

Here are some useful links:

Combining C and tcl/tk
[An Overview of the Tk C Library][2]

Remo.D
  • 16,122
  • 6
  • 43
  • 74
7

Here's a reference: http://www.hume.com/html85/indexes/tkc_api.html

Intro to combine C with Tk: http://davesource.com/Fringe/.../tcl_tk/tcl_C.html