Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Tk using C
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.



Report this thread to moderator Post Follow-up to this message
Old Post
Bart C
12-17-04 08:59 PM


Re: Tk using C
"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.



Report this thread to moderator Post Follow-up to this message
Old Post
Bart C
12-18-04 05:52 PM


Re: Tk using C
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 thing
s
> 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*

Report this thread to moderator Post Follow-up to this message
Old Post
Dariusz Kuliński / TaKeDa
12-18-04 08:56 PM


Re: Tk using C
"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:
 

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




Report this thread to moderator Post Follow-up to this message
Old Post
Bart C
12-19-04 01:57 AM


Re: Tk using C
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

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Cassidy
12-19-04 08:56 AM


Re: Tk using C
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Cameron Laird
12-20-04 01:57 AM


Re: Tk using C
"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.



Report this thread to moderator Post Follow-up to this message
Old Post
Bart C
12-20-04 08:57 AM


Re: Tk using C
"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/

Report this thread to moderator Post Follow-up to this message
Old Post
David N. Welton
12-20-04 01:59 PM


Re: Tk using C
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.


Report this thread to moderator Post Follow-up to this message
Old Post
Donal K. Fellows
12-20-04 01:59 PM


Re: Tk using C
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/

Report this thread to moderator Post Follow-up to this message
Old Post
David N. Welton
12-20-04 01:59 PM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

Tcl archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:46 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.