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?
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.
The C or C++ code that implements a Tcl command is called a command procedure. The interface to a command procedure is much like the interface to a main program. The inputs are an array of values that correspond exactly to the arguments in the Tcl script command.
Tk is a graphical user interface toolkit that takes developing desktop applications to a higher level than conventional approaches. Tk is the standard GUI not only for Tcl, but for many other dynamic languages, and can produce rich, native applications that run unchanged across Windows, Mac OS X, Linux and more.
The Tk toolkit is a cross-platform collection of 'graphical control elements', aka widgets, for building application interfaces. If you want to take advantage of the latest version of Tkinter, you'll need to install a version of Python that supports Tcl/Tk 8.5 or greater.
Here are some useful links:
Combining C and tcl/tk
An Overview of the Tk C Library
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With