For Programmers: Free Programming Magazines  


Home > Archive > Tcl > December 2004 > Tk using C









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Tk using C
Bart C

2004-12-17, 3:59 pm

I've seen Tkinter at work in Python.

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.


Bart C

2004-12-18, 12:52 pm

"Bart C" <bc@freeuk.com> wrote in message news:41c2fe0a@212.67.96.135...
> I've seen Tkinter at work in Python.
>
> Can I do something similar in C language?


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.


Dariusz Kuliński / TaKeDa

2004-12-18, 3:56 pm

On Sat, 18 Dec 2004 16:27:34 -0000, Bart C wrote:

> 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

--
takeda@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*
Bart C

2004-12-18, 8:57 pm


"Dariusz Kulinski / TaKeDa" <5570bmv02@NOsneakemailSPAM.com> wrote in
message news:wu3ybnoigujc.dlg@stupidworms.takeda.tk...
> On Sat, 18 Dec 2004 16:27:34 -0000, Bart C wrote:


[color=darkred]
> 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>



Steve Cassidy

2004-12-19, 3:56 am

Bart C wrote:

> 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
Cameron Laird

2004-12-19, 8:57 pm

In article <41c4e0cc$0$1121$afc38c87@news.optusnet.com.au>,
Steve Cassidy <Steve.Cassidy@mq.edu.au> wrote:
>Bart C wrote:
>
>
>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.

Bart C

2004-12-20, 3:57 am


"Cameron Laird" <claird@lairds.us> wrote in message
news:hdeh92-c2f.ln1@lairds.us...


> 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.


David N. Welton

2004-12-20, 8:59 am

"Bart C" <bc@freeuk.com> writes:

> 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/
Donal K. Fellows

2004-12-20, 8:59 am

Bart C wrote:
> I'm not even sure why they are separate (why not Tkl?).


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.

David N. Welton

2004-12-20, 8:59 am


I guess I should wake up before I post in the morning...

--
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/
Cameron Laird

2004-12-20, 8:59 am

In article <41c6257e@212.67.96.135>, Bart C <bc@freeuk.com> wrote:
Ralf Fassel

2004-12-22, 4:04 pm

* "Bart C" <bc@freeuk.com>
| 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.

M$ gives away the commandline version of the VC++ compiler for free,
see

http://msdn.microsoft.com/visualc/vctoolkit2003/

for the details.

R'
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com