Can I do something similar in C language?
I want to build dialog windows in C using the tk-like functions I saw in
Python.
Thanks
Bart.
What I've found so far suggests this is in fact possible but finding things
out is proving nigh impossible.
Most references are geared to using tcl itself or via Python.
I have found (this is for Windows):
* tk/tcl C header files
* tk/tcl DLL files containing lots of interesting functions
* A code fragement in C that creates what looks like a tk window (not
compileable yet)
* LIB files which could be for those dlls
What I'm missing is:
* API docs for the C interface
* Just one simple program to get a window and a button working then I can
work from there. So far stalled by weird compiler errors, from 2 different C
compilers, trying to compile the code fragment. I'm sure that linking will
be fun as well.
Any reassurance that I am on the right lines and that I'm not wasting my
time trying something that is not possible would be appreciated.
Bart.
> What I've found so far suggests this is in fact possible but finding things
> out is proving nigh impossible.
>
> Most references are geared to using tcl itself or via Python.
>
> I have found (this is for Windows):
>
> * tk/tcl C header files
> * tk/tcl DLL files containing lots of interesting functions
> * A code fragement in C that creates what looks like a tk window (not
> compileable yet)
> * LIB files which could be for those dlls
>
> What I'm missing is:
>
> * API docs for the C interface
> * Just one simple program to get a window and a button working then I can
> work from there. So far stalled by weird compiler errors, from 2 different C
> compilers, trying to compile the code fragment. I'm sure that linking will
> be fun as well.
>
> Any reassurance that I am on the right lines and that I'm not wasting my
> time trying something that is not possible would be appreciated.
>
> Bart.
I think you should look there:
http://www.tcl.tk/man/
Here is probably what you're looking for:
http://www.tcl.tk/man/tcl8.4/TkLib/contents.htm
--
tak...@IRCnet.EFnet, ICQ# 15827691, TLEN: taked4
*http://eggdrop.takeda.tk - forum dot. botów na bazie eggdropa*
*http://eggwiki.takeda.tk - pomoc w używaniu botów po polsku*
>> What I'm missing is:
>>
>> * API docs for the C interface
> I think you should look there:
> http://www.tcl.tk/man/
>
> Here is probably what you're looking for:
> http://www.tcl.tk/man/tcl8.4/TkLib/contents.htm
OK thanks. I just need now a compiler that will work properly, I've tried 3
or 4 so far, but some more free ones still to go.
Bart.
lcc-win32:
complains about one of the decls in tcldecls.h but is no different from
those before or after
digitalmars C:
compiles headers but needs explicit cast in this line in the test
program:
mainWindow = Tk_CreateMainWindow( interp, display, argv[0] , "Tk")
Pelles C:
Had trouble compiling <windows.h> and loads of errors in tcl headers
gcc/Mingw:
Got nowhere. Didn't even have <stdio.h>
....
> OK thanks. I just need now a compiler that will work properly, I've tried
> 3 or 4 so far, but some more free ones still to go.
I've given up on C compilers.
I can use non-conventional methods to access and call the functions in the
TK/TCL84.DLL files.
But it would be useful to know:
* Do the TK/TCL functions use Windows or C calling conventions? Ie. are
the params pushed right to left or left to right, and is stack adjustment
required by the caller?
Thanks.
Bart.
>* Do the TK/TCL functions use Windows or C calling conventions? Ie. are
>the params pushed right to left or left to right, and is stack adjustment
>required by the caller?
Windows is an operating system, C is a programming language.
They may each support their own parameter evaluation ordering -
how would *you* rationalize the evaluation ordering of a C program running
under Windows?
It is far more likely that the operating system and/or the hardware
architecture is the driving force for the employed evaluation order,
particularly if you wish to link/call functions across different languages.
Moreover, C does not define a single parameter evaluation ordering.
The best advice for writing portable programs, is to never be reliant on
the order of parameter evaluation aand passing.
______________________________________________________________________________
Dr Chris McDonald E: ch...@csse.uwa.edu.au
Computer Science & Software Engineering W: http://www.csse.uwa.edu.au/~chris
The University of Western Australia, M002 T: +618 6488 2533
Crawley, Western Australia, 6009 F: +618 6488 1089
> OK thanks. I just need now a compiler that will work properly, I've tried 3
> or 4 so far, but some more free ones still to go.
>
Umm, so you want to call Tk directly from C but you don't have a working
C compiler...mingw/gcc is the answer to how to build Tcl and Tk on
Windows, there are documents on the wiki (http://mini.net/tcl/)
describing how to go about this.
Tk doesn't have an explicit interface to creating and making use of
widgets from C, it's geared towards making things accessible to Tcl
scripts. That's why the Python interface works by embedding the
tcl interpreter and implementing Tkinter calls as calls to snippets of
tcl code. You could do the same from C via the Tcl_Eval interface. It's
not clear what you'd gain from doing this however.
The Tcl way of doing things is to write C coded extensions for
particular bits of functionality (like signal processing, hardware
interfacing, etc) and then write the interface in Tcl calling out to
your C code when needed. This works really well, as many would testify here.
Steve
Bart, Mingwin certainly works in this role for quite a
few of us. I wonder, though, if you realize how com-
fortable it can be to work with Tk from Tcl itself. I
understand you began with Tkinter, and have some reason
for looking for an alternative. The Tcl interpreter
can be a great vehicle for accessing Tk *and* C-coded
objects. Does that help?
> Bart, Mingwin certainly works in this role for quite a
> few of us. I wonder, though, if you realize how com-
> fortable it can be to work with Tk from Tcl itself. I
> understand you began with Tkinter, and have some reason
> for looking for an alternative. The Tcl interpreter
> can be a great vehicle for accessing Tk *and* C-coded
> objects. Does that help?
I've *admired* tkinter in Python (never used it though), and wanted to
import the functionality into my non-C/non-Python application. I also write
compilers/interpreters so for me bypassing the idiosyncrasies of C compilers
is both attractive and viable, if rather more work (rewriting headers for
example).
But you're right, I should learn Tk/Tcl first, I'm not even sure why they
are separate (why not Tkl?). I'm doing that now. And in the long term I
should obtain a proper C compiler, although anything gcc-connected seems
large and daunting (some 200 pages? just of command-line options seemed a
bit OTT).
Bart.
> But you're right, I should learn Tk/Tcl first, I'm not even sure why
> they are separate (why not Tkl?). I'm doing that now. And in the
> long term I should obtain a proper C compiler, although anything
> gcc-connected seems large and daunting (some 200 pages? just of
> command-line options seemed a bit OTT).
The reason they are linked together is a clever one linked to the idea
behind Tcl. To wit, that it's much faster and more flexible to write
code in a scripting language than with a compiled language like C.
The logical conclusion for Tk is that it makes sense to do the low
level basics that must be as fast as possible in C, and then build up
from that as scripts. So what you see as 'Tk' actually includes a lot
of Tcl code, and thus requires Tcl itself.
What's ironic about this is that at times it makes people from *other*
scripting language communities turn their noses up. They would prefer
having everythin in lowest-common-denominator-C... An interesting
conundrum.
Ciao,
--
David N. Welton
Personal: http://www.dedasys.com/davidw/
Apache Tcl: http://tcl.apache.org/
Free Software: http://www.dedasys.com/freesoftware/
Linux Incompatibility List: http://www.leenooks.com/
They are separate because many people want to use just Tcl and not Tk
at all (e.g. in server environments, which is another significant use
for Tcl). Add to that the fact that they started out with Tk being an
extension to Tcl (though from the same author) and you've got why
things are the way they are.
Donal.
I don't understand your relation to C compilers. One
growing capability of Tcl, though, is as a language
for writing compilers <URL: http://wiki.tcl.tk/3687 >.
I repeat: perhaps you'll be able to do *everything*
you want in Tcl alone.
M$ gives away the commandline version of the VC++ compiler for free,
see
http://msdn.microsoft.com/visualc/vctoolkit2003/
for the details.
R'