Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Tk with C

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?

like image 808
J. C. Salomon Avatar asked Dec 18 '11 05:12

J. C. Salomon


People also ask

Can I use tkinter with C?

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.

What do you mean by C interface in Tcl?

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.

What is Tk programming?

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.

What is Tk version?

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.


1 Answers

Here are some useful links:

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

like image 67
OutOfBoundsException Avatar answered Sep 27 '22 19:09

OutOfBoundsException