f



Using Tcl/Tk as a user interface in a C program

Hi,

i thought this question would come up every day, but i read this
NG for a while and haven't seen it since.

What i'd like to do is use Tcl/Tk in a standalone (linked against
Tcl and/or Tk libs) C program.

I'd like to open Windows and call Tcl scripts from C that handle
the windows.  I wouldn't like to have external scripts called, but
i'd like to embed it in the C program.

Has anybody got a short example for that (Linux / Windows)?


Thanks for any hints,
Torsten.

0
Torsten
11/18/2003 7:05:35 PM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

11 Replies
799 Views

Similar Articles

[PageSpeed] 39

MkTclApp is your friend:

	http://www.hwaci.com/sw/mktclapp/index.html

Pretty simple, really.


On Tue, 18 Nov 2003, Torsten Mohr wrote:

> Date: Tue, 18 Nov 2003 20:05:35 +0100
> From: Torsten Mohr <tmohr@s.netic.de>
> Newsgroups: comp.lang.tcl
> Subject: Using Tcl/Tk as a user interface in a C program
>
> Hi,
>
> i thought this question would come up every day, but i read this
> NG for a while and haven't seen it since.
>
> What i'd like to do is use Tcl/Tk in a standalone (linked against
> Tcl and/or Tk libs) C program.
>
> I'd like to open Windows and call Tcl scripts from C that handle
> the windows.  I wouldn't like to have external scripts called, but
> i'd like to embed it in the C program.
>
> Has anybody got a short example for that (Linux / Windows)?
>
>
> Thanks for any hints,
> Torsten.
>
>
0
Spam159 (460)
11/18/2003 8:25:29 PM
* Torsten Mohr <tmohr@s.netic.de>
| I'd like to open Windows and call Tcl scripts from C that handle
| the windows.  I wouldn't like to have external scripts called, but
| i'd like to embed it in the C program.

Instead of providing .tcl files, you could add a

        char script[] = "\
    set foo bar\n\
    proc foo {args} {\n\
      puts \"this is foo $args\"\n\
    }"

Create and init the interp as usual, then eval that script
    Tcl_Eval(interp, script);
to introduce your code to tcl.
    
However, quoting will quickly become a nightmare when things get more
complicated than that little example.

R'
<mumble>
Another way would be to alloc some kB for the script, fill that region
with a well-known bitpattern, compile the program, and dump the script
into the compiled executable via some other means, replacing the
well-known bitpattern.
</mumble>
0
ralfixx (1283)
11/18/2003 8:32:53 PM
Torsten Mohr <tmohr@s.netic.de>
>| I'd like to open Windows and call Tcl scripts from C that handle
>| the windows.  I wouldn't like to have external scripts called, but
>| i'd like to embed it in the C program.
 
Ralf Fassel wrote:
> Instead of providing .tcl files, you could add a
> 
>         char script[] = "\
>     set foo bar\n\
>     proc foo {args} {\n\
>       puts \"this is foo $args\"\n\
>     }"
> 
> Create and init the interp as usual, then eval that script
>     Tcl_Eval(interp, script);
> to introduce your code to tcl.

Note that he wants the Tcl scripts to "handle the windows", so he's
looking to use Tk, and will have to deal with servicing the event
loop.

It's probably a much better idea to turn the functions of his C program
into Tcl commands provided by a package, and load them into wish,
than to attempt it the other way around.

It's a shame people always wait to ask these questions until they've
already painted themselves into an architecture that makes things
hard.

-- 
| Don Porter          Mathematical and Computational Sciences Division |
| donald.porter@nist.gov             Information Technology Laboratory |
| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|
0
dgp1 (946)
11/18/2003 9:02:30 PM
In article <slrnbrl275.he2.dgp@clover.cam.nist.gov>,
Don Porter  <dgp@nist.gov> wrote:
>Torsten Mohr <tmohr@s.netic.de>
>>| I'd like to open Windows and call Tcl scripts from C that handle
>>| the windows.  I wouldn't like to have external scripts called, but
>>| i'd like to embed it in the C program.
> 
>Ralf Fassel wrote:
>> Instead of providing .tcl files, you could add a
			.
			.
			.
>Note that he wants the Tcl scripts to "handle the windows", so he's
>looking to use Tk, and will have to deal with servicing the event
>loop.
>
>It's probably a much better idea to turn the functions of his C program
>into Tcl commands provided by a package, and load them into wish,
>than to attempt it the other way around.
>
>It's a shame people always wait to ask these questions until they've
>already painted themselves into an architecture that makes things
>hard.
			.
			.
			.
"... servicing the event loop":  correct.

"It's a shame ...":  correct.

"It's probably a much better idea ...":  correct--but we can
say this in a slightly stronger form.  Here's the alternative
I propose:  going "inside out" by extending Tcl rather than
embedding it, is the preference of most current Tcl experts.
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
11/18/2003 9:58:18 PM
Torsten Mohr <tmohr@s.netic.de> wrote:

>Hi,
>
>i thought this question would come up every day, but i read this
>NG for a while and haven't seen it since.
>
>What i'd like to do is use Tcl/Tk in a standalone (linked against
>Tcl and/or Tk libs) C program.
>
>I'd like to open Windows and call Tcl scripts from C that handle
>the windows.  I wouldn't like to have external scripts called, but
>i'd like to embed it in the C program.
>
>Has anybody got a short example for that (Linux / Windows)?
>
>
>Thanks for any hints,
>Torsten.

Here's an example how to create a container your app provides for Tk's use
(see bottom of page):  http://mini.net/tcl/2870

That might not be your direction, though.

Here's a library I wrote to allow Tcl to service it's event loop
irregardless of the main loop mechanism used by the application it is
embedded into:  http://mini.net/tcl/2075

It might be possible to attach an internal VFS to the executable like a
starpac, but use your exe as the shell for it.
-- 
David Gravereaux <davygrvy@pobox.com>
[species: human; planet: earth,milkyway(western spiral arm),alpha sector]
0
davygrvy (1376)
11/18/2003 10:26:34 PM
claird@lairds.com (Cameron Laird) wrote:

>"... servicing the event loop":  correct.
>
>"It's a shame ...":  correct.
>
>"It's probably a much better idea ...":  correct--but we can
>say this in a slightly stronger form.  Here's the alternative
>I propose:  going "inside out" by extending Tcl rather than
>embedding it, is the preference of most current Tcl experts.

Embedding is the road less traveled.  Possible?, yes.  Difficult?, yes.

See http://www.tcl.tk/doc/integration.html#Tcl for a model discussion.  If
your custom C can be represented as an extension without a visual
component, using wish as the shell might be more correct than taking your
existing application and embedding tcl/tk into it.  Than again, if your C
component is mostly interface already, embedding tcl/tk into your
application as an add-on might be the correct way to go in that case.  Do
realize that embedding is more complicated.
-- 
David Gravereaux <davygrvy@pobox.com>
[species: human; planet: earth,milkyway(western spiral arm),alpha sector]
0
davygrvy (1376)
11/18/2003 10:38:31 PM
In article <7a7lrvcs0it04oqrchlli2h7p3oqbnef3o@4ax.com>,
David Gravereaux  <davygrvy@pobox.com> wrote:
			.
			.
			.
>>"It's probably a much better idea ...":  correct--but we can
>>say this in a slightly stronger form.  Here's the alternative
>>I propose:  going "inside out" by extending Tcl rather than
>>embedding it, is the preference of most current Tcl experts.
>
>Embedding is the road less traveled.  Possible?, yes.  Difficult?, yes.
>
>See http://www.tcl.tk/doc/integration.html#Tcl for a model discussion.  If
>your custom C can be represented as an extension without a visual
>component, using wish as the shell might be more correct than taking your
>existing application and embedding tcl/tk into it.  Than again, if your C
>component is mostly interface already, embedding tcl/tk into your
>application as an add-on might be the correct way to go in that case.  Do
>realize that embedding is more complicated.
			.
			.
			.
Since David's been so even-handed in explaining this, I'll go over
to the other side now and give a couple of reasons *to* embed:
1.  That was historically Tcl's strength.  It originated
    as a library-to-be-embedded, and was a shell-to-be-
    extended only secondarily.
2.  Significant top practitioners--Davy, for example, 
    who modestly failed to mention such work as <URL:
    http://wiki.tcl.tk/tes >, or Richard Hipp, with
    the mktclapp to which the original poster was al-
    ready referred--favor embedding.
3.  <URL: http://wiki.tcl.tk/HowToEmbed > is available.
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
11/18/2003 10:57:22 PM
* Don Porter <dgp@email.nist.gov>
| Note that he wants the Tcl scripts to "handle the windows", so he's
| looking to use Tk, and will have to deal with servicing the event
| loop.

Yup.  If the OP is into creating widgets, then he will need to embed
the whole set of Tk scripts for those widgets into his app, too.  I
had not thought of that initially, but the reference to `mktclapp' in
another post made it clear.

Sounds for me like it is not worth the trouble.  The only advantage
would be to have one ready-to-run .exe as compared to a .zip which has
to be extracted somewhere.  The disk space requirements would be
similar, unless some compression technique is used in the embedded
version (gzip the scripts and unzip them at runtime).

R'
0
ralfixx (1283)
11/18/2003 11:16:35 PM
claird@lairds.com (Cameron Laird) wrote:

>Since David's been so even-handed in explaining this

I've been humbled by this weekend's work :(  I tried to make a custom
window type (in my win32 GUI app) act as a container for Tk.  Got it
working by copying what the plugin does, but for the life of me, I just
don't know how to enable resizing.  I just can't figure it out.  It works
out-of-process, but not in-process (??)

I'm way confused...  I don't think people do this stuff.. 'cept for me
cause i'm nutts.
-- 
David Gravereaux <davygrvy@pobox.com>
[species: human; planet: earth,milkyway(western spiral arm),alpha sector]
0
davygrvy (1376)
11/19/2003 2:09:56 AM

David Gravereaux wrote:
> claird@lairds.com (Cameron Laird) wrote:
> 
> 
>>Since David's been so even-handed in explaining this
> 
> 
> I've been humbled by this weekend's work :(  I tried to make a custom
> window type (in my win32 GUI app) act as a container for Tk.  Got it
> working by copying what the plugin does, but for the life of me, I just
> don't know how to enable resizing.  I just can't figure it out.  It works
> out-of-process, but not in-process (??)
> 
> I'm way confused...  I don't think people do this stuff.. 'cept for me
> cause i'm nutts.

Don't be so hard on yourself, it's a thin line between
genious and insanity. Each time I see a post I think it's
one of them, and the next post I usually change my mind ;)

Bruce

0
bruce-news (900)
11/19/2003 3:05:03 PM
Bruce Hartweg <bruce-news@hartweg.us> wrote:

>
>
>David Gravereaux wrote:
>> claird@lairds.com (Cameron Laird) wrote:
>> 
>> 
>>>Since David's been so even-handed in explaining this
>> 
>> 
>> I've been humbled by this weekend's work :(  I tried to make a custom
>> window type (in my win32 GUI app) act as a container for Tk.  Got it
>> working by copying what the plugin does, but for the life of me, I just
>> don't know how to enable resizing.  I just can't figure it out.  It works
>> out-of-process, but not in-process (??)
>> 
>> I'm way confused...  I don't think people do this stuff.. 'cept for me
>> cause i'm nutts.
>
>Don't be so hard on yourself, it's a thin line between
>genious and insanity. Each time I see a post I think it's
>one of them, and the next post I usually change my mind ;)
>
>Bruce

Today I'm running on a new theory.  For out-of-process, I ignore
TK_GEOMETRYREQ between WM_ENTERSIZEMOVE and the closing WM_EXITSIZEMOVE
(which works), but for in-process messages are delayed and all
TK_GEOMETRYREQ messages are sent after the closing WM_EXITSIZEMOVE and
angrily enough the counts don't match.  I think the delay is until Tcl's
event loop hits idle because a) the window is created in Tcl's thread so
therefore Tk (by way of Tcl's event loop) is servicing its messages b)
geometries are idle events and c) I'm out of any other ideas.

Melding of event loops is no fun..  Time for threading, again..  I keep
coming back to that..  That's a separate thread per MDI child window.  I
don't know if I like this.
-- 
David Gravereaux <davygrvy@pobox.com>
[species: human; planet: earth,milkyway(western spiral arm),alpha sector]
0
davygrvy (1376)
11/19/2003 9:19:51 PM
Reply:

Similar Artilces:

Opening a TCL program from within another TCL program in ANSYS Tcl-Tk
Hi everyone, I have been pulling my hair with this one for a couple of days and still have not found a fix. I'm working within ANSYS Tcl-Tk implementation. I created a Tcl-Tk script that generates a simple window with three buttons. Each button opens another window which is created in a separate Tcl file. The second window have a lot of text entries, variables, procedures, etc. I can open the second Tcl file by itself and everything works as supposed, but when I open it using the button in the first window, it opens but any procedure called by the widgets on the second window are not found... Here's the deal... Since I'm working within the ANSYS implementation of Tcl-Tk, I'm actually using an ANSYS command to open the second window. The command I use is: ### ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/ IBR_CAS.tcl' ### It actually sends a command back to ANSYS telling it to execute a Tcl command... I know this is not pretty but its the only way i was able to make it at least show the window. ############################## #Main Tcl (excerpt): ############################## namespace eval Tools { proc IBRCambpell {} { #source O:/mad_projects_2/ANSYS/Macros/IBR_CAS.tcl ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/ IBR_CAS.tcl' } proc viewManager {} { ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/ ViewManager.tcl' } proc powerAnnotation {} { ans_sendcommand ~eui,'source ...

how to access prolog from tcl?(not using tcl/tk interface from prolog)
hi, I am now doing my thesis project relate to mobile agent technology which need to access prolog from tcl. There are a lot of prologs which have the function to access tcl from prolog, but I need to access prolog from tcl.(I can not use the method that first load prolog, then access tcl via the interface, and reload prolog). So is there any one can help me or give me some tips to solve this problem? Now I can only found one article to solve this problem(http://tkoutline.sourceforge.net/wiki/38). I tried the code, but unfortunately, the terminal always crashed and did not give any response when I run the second command of its example---"% prolog::init". I could run the command of "plcon -s interp.pl -t main -q" in DOS terminal without problem. Originally I thought it is the version problem of tcl, so I changed it from 8.4.9 to 8.0.3, but the problem was still there. My SWI-prolog version is 3.1.2. My operating system is winXP. I am now very nervous about that, Please give me some help to solve this problem, or tell me some other way to access prolog from tcl. Thank you very much I did not give up the solution of (http://tkoutline.sourceforge.net/wiki/38). Now I changed SWI-prolog version to 5.4.4. When I run the second command(prolog::init) of the example from wish.exe, it pop up a window, said that Prolog interpreter closed unexpectedly Prolog interpreter closed unexpectedly while executing "error "Prolog interpreter closed unexpect...

create a tcl/tk interface for a c program
Hi, I have an application in c (a client for a news server). The application is working and running, the problem is that it is in command line mode. I want to create a separate tcl/tk interface that will control my c program; something like executing it, and reading the c-program results from the prompt and dealing with it... I need the two programs to be separated, and I don't need it to be a standalone program, I just need to launch the client from the tcl/tk interface and retrieve all messages in textbox or tables, and all the communication between the user and the c program would have to be through the tcl/tk interface. I am very familiar with programing in both languages, but I don't know where and how to start :) So I will be very thankfull if anyone can give me some advice or a link to any tutorial explaining how to do this. Thanks everyone Achraf In article <187af06a.0311182019.6a878c4d@posting.google.com>, Achraf El Youssoufi <991BE733792@stud.alakhawayn.ma> wrote: >Hi, > > I have an application in c (a client for a news server). The >application is working and running, the problem is that it is in >command line mode. I want to create a separate tcl/tk interface that >will control my c program; something like executing it, and reading >the c-program results from the prompt and dealing with it... > > I need the two programs to be separated, and I don't need it to be a >standalone program, I just...

[TCL/TK interface] Passing variable to TCL/TK
Hi, I am trying to sent to a variable to tcl/tk and unify there it with a string. I wrote the prolog code: :- use_module(library(tcltk)). :- use_package(classic). go(A):- tk_new([name('Simple')], Tcl), tcl_eval(Tcl, 'source simple2.tcl', _), tcl_eval(Tcl, ['ask', br(write(A))], _), tk_main_loop(Tcl), tcl_delete(Tcl). and the tcl file simple2.tcl proc ask {var} { unify_term $var my_value } unfortunatelly when I query for go(S). the interpeter goes into a loop (!?). Where I am wrong. Are there any example code somewhere i...

YouTube Playlist: Tcl/Tk Object Oriented Programming Using Itcl (incr Tcl) Lessons
Hi. Like I promised you hours ago.. The playlist in English : https://www.youtube.com/playlist?list=PLsAEIIjTPIo_1qeuc-rYwk0nxWAM38Dl_ The same playlist in Arabic : https://www.youtube.com/playlist?list=PLsAEIIjTPIo_91kA-iUz_5XGNmHzivHBG Enjoy! On Saturday, January 17, 2015 at 4:04:21 PM UTC+2, Rani Ahmad wrote: > Hi. > > Like I promised you hours ago.. > > The playlist in English : > > https://www.youtube.com/playlist?list=PLsAEIIjTPIo_1qeuc-rYwk0nxWAM38Dl_ > > The same playlist in Arabic : > > https://www.youtube.com/playli...

l'C program executing from a tcl script with pipe opened using open command in Tcl
Hi all, I wanted to communicate with a C program from a Tcl script.. The test code i have written is below Both the 'C' program and Tcl script are located in the same directory. The 'C' program is below. I have named it CTCL.C #include<stdio.h> #include<string.h> int main() { int i; char c[30]; printf("Reading..."); scanf("%s",c); printf("String read is :%s\n",c); fflush(stdout); return 0; } I have compiled the program with the command cc CTCL.C -o ctcl So the executable was generated with the name 'ctcl' The Tcl script I have written is. I have named it TCLPIPETEST.tcl #!/usr/add-on/exptools/bin/tclsh set fd [open "|./ctcl" r+] gets $fd tmp1 puts "tmp1 = $tmp1" set stat 0 set tmp2 "Default value... " if { ![catch { puts $fd "abcdef" } res]} { if { ![catch { flush $fd } res] } { if { ![catch { gets $fd tmp2} res ] } { set stat 1 } else { puts "Error 'gets' from pipe : $res" } } else { puts "Error 'flush' from pipe:$res " } } else { puts "Error 'puts' from pipe:$res " } if { $stat == 1 } { puts "Success......:$tmp2 :)" } else { puts "Failure......:$tmp2 :(" } I have given all permissions for both the files above. When i execute the Tcl script My aim is to open a pipe with the 'C' executable 'ctcl', initially read so...

Using Tcl/Tk 8.4.7 from C/C++
Hi, I just discovered Tcl/Tk and fairly excited about it :) I'm interested in using both Tcl/Tk on one c++ project and only Tk on another c++ project. 1. C++ Tk only project: I'm interested in using Tk within my c/c++ project. The project only has 5-6 dialogs using just the standard widgets. Is it fairly common to use Tk directly from c/c++--and is it fairly easy? 2. C++ Tcl/Tk only project: I'm interested in using both Tcl and Tk from within a c/c++ application. Is maketclapp the best way to go or are there better ways? Maketclapp doesn't seem to have been updated in a while...but the security features (hiding tcl source) is compelling for this particular project. Thanks. ...

FAQ (unanswered): possible to use Tk without Tcl (in c/c++)
Googling turned up dozens of questions about using tk without tcl. But there doesn't seem to be a clear answer. Is it possible to use Tk without Tcl? Specifically, I'd like to use Tk from c/c++ without using Tcl. More specifically, I'd like to statically link in the Tk library and use it directly from c/c++. H. Simpson wrote: > Googling turned up dozens of questions about using tk without tcl. But > there doesn't seem to be a clear answer. > > Is it possible to use Tk without Tcl? > > Specifically, I'd like to use Tk from c/c++ without using Tcl. More > specifically, I'd like to statically link in the Tk library and use it > directly from c/c++. The Perl/Tk people did it. The Python/Tkinter people took the other route of embedding a Tcl interpreter along with it. It is possible, but its wasting a lot of Tk's capabilities, that come from the Tcl language. A second problem is the Tk C-Api. Do you have any special reasons to use Tk without Tcl? Michael Michael Schlenker wrote: > H. Simpson wrote: > >> Googling turned up dozens of questions about using tk without tcl. >> But there doesn't seem to be a clear answer. >> >> Is it possible to use Tk without Tcl? >> >> Specifically, I'd like to use Tk from c/c++ without using Tcl. More >> specifically, I'd like to statically link in the Tk library and use it >> directly from c/c++. >...

Tcl interface to C program
I am developing a program (a game) that has two main states: one is the actual game which is a low-level full screen C program that must be very optimized; the other is a textual interface where the player sets options like difficulty, save games, colors, etc. For example, while playing the game the user can press Esc to pause the game and go into the text interface. I was thinking of using Tcl as the text interface. Does anyone have any pointers on how to do this? I would like to design it so the main() part of the program is Tcl, with a command lets the user switch into the full screen C game (which would be like a module). How does that work? Can it all be combined into one executable file? Any help would be appreciated. bluejolts@gmail.com schrieb: > I am developing a program (a game) that has two main states: one is > the actual game which is a low-level full screen C program that must > be very optimized; the other is a textual interface where the player > sets options like difficulty, save games, colors, etc. For example, > while playing the game the user can press Esc to pause the game and go > into the text interface. text interface aka tty on unix or dos console on windows? Another option would be to use Tk for a gui. > > I was thinking of using Tcl as the text interface. Does anyone have > any pointers on how to do this? For tty's look at the tcllib term package, which does ansi escape sequences and cursor movement stuff in ansi...

E.J. Friedman-Hill's Tcl/Tk Course
E.J. Friedman-Hill's Tcl/Tk Course Tcl/Tk Programming in Five Easy Lessons http://www.linbox.com/ucome.rvt/any/doc_distrib/tcltk-8.3.2/TclCourse/ I am unable to open the ppt files that seem very promising. Can anyone see what is the problem with them and can convert/fix so that I can open in the office 2007 or open office ? Thanks Bolega On 24/03/2011 2:51 AM, bolega wrote: > E.J. Friedman-Hill's Tcl/Tk Course > Tcl/Tk Programming in Five Easy Lessons > > http://www.linbox.com/ucome.rvt/any/doc_distrib/tcltk-8.3.2/TclCourse/ > > I am unable to o...

In Tcl and C++ code, how to use Tcl Command, such as exit?
In my code, i used Tcl_SetStdChannel(0, STDIN) and a thread to control all input and output from Tcl, but i want to use some of Tcl' Commands, such as, exit. I used Tcl_Eval() then, but the Tcl command seem invisible in my code, I typed a string in command prompt, such as "AAAAA", and Enter, got nothing feedback. How can i do to get these Tcl Commands work? Thanx! vian1381@china.com.cn wrote: > In my code, i used Tcl_SetStdChannel(0, STDIN) and a thread to control > all input and output from Tcl, but i want to use some of Tcl' Commands, > such as, exit. > > I used Tcl_Eval() then, but the Tcl command seem invisible in my code, > I typed a string in command prompt, such as "AAAAA", and Enter, got > nothing feedback. Your questions are hard to understand, but they suggest that you believe that setting a custom stdin channel will do some magic to establsh a prompt/read/eval loop. That is not the case. > How can i do to get these Tcl Commands work? Start with something that works, like the source code for tclsh, and adapt to your needs. Or post a followup and include more code examples to explain what you're doing and how it doesn't do what you expect. -- | Don Porter Mathematical and Computational Sciences Division | | donald.porter@nist.gov Information Technology Laboratory | | http://math.nist.gov/~DPorter/ NIST | |_____________________________________...

question about tcl/tk and c program
In my Tcl/Tk scripts, I want to program different branches according to the result of my C extension procedures. In the C procedure, we usually use such codes as follow: int CountStart(ClientData clientData, Tcl_Interp *interp,int argc, char *argv[]) { ............... ................ interp->result = "end vpstart."; //return TCL_OK; return TCL_ERROR; } In Tcl/Tk scripts, we can use "set ret [count_start $sym]" or "catch {count_start $sym} ret" to call the C procedure CountStart. The variable "ret" is assigned with the string which was saved in "interp->result". Now I want it can return 0 or 1 or 2 in the C procedure CountStart, and then it can identify the result when call the c procedure in Tcl/Tk scripts. I just want identify the number which is in the "return ...." sentence, not in the interp->="....". How can I do this? Best Regards Guo "sunnyboyGuo@gmail.com" <sunnyboyGuo@gmail.com> wrote: # In my Tcl/Tk scripts, I want to program different branches according to # the result of my C extension procedures. # In the C procedure, we usually use such codes as follow: # int CountStart(ClientData clientData, Tcl_Interp *interp,int argc, char # *argv[]) # { # .............. # ............... # interp->result = "end vpstart."; # //return TCL_OK; # return TCL_ERROR; # } # In Tcl/Tk scripts, we can use "set ret [count_start $sym]" or # "...

C++/Tcl/C++ Interface
Hi, I'm a newbie in Tcl and Tcl/C++ interfacing. I need to develop a prototype for one of our upcoming project. I've a shared library which provides Tcl procedures to traverse through some graph which is being created upon reading a file of specific format. If I load this shared library in Tcl shell and call those proc to read the specific file and traverse the graph. Graph traversal proc are like: * getting neighbor nodes of a given node * getting the node name and edge names to/from a node Let's name this Tcl library GL (graph lib). Now, in my C++ program I need create a duplicate graph since I don't have capability read that file directly. So from my C++ code, I need to create a Tcl channel, send commands through the Tcl channel for GL procs and get information from those GL procs to my C++ application to build a duplicate graph on my end. Could some one provide hints how to go about this? Any pointers to existing resource (doc/open source code) will be very helpful. Please redirect me to correct group if this is not the most appropriate one. Regards, ~ Soumen Soumen wrote: > Hi, > > I'm a newbie in Tcl and Tcl/C++ interfacing. I need to develop a > prototype for one > of our upcoming project. > > I've a shared library which provides Tcl procedures to traverse > through some graph > which is being created upon reading a file of specific format. If I > load this shared > library in Tcl shell and ca...

tcl-mmap: A POSIX mmap interface for Tcl. (Tcl package)
This is an announcement for a relatively new Tcl project: tcl-mmap Tcl-mmap is a Tcl interface to the POSIX mmap* system call. It provides a Tcl package that allows Tcl scripts to: 1) Memory map files for improved access efficiency; 2) Share memory between related processes; 3) Easily implement cyclic persistent log files. * See the mmap(2) man page. Platform: Linux/Unix Home page: http://sourceforge.net/projects/tcl-mmap/ Man page: http://tcl-mmap.sourceforge.net/ Author: Alexandros Stergiakis On Sep 3, 11:48=A0am, Alexandros Stergiakis <alst...@gmail.com> wrote: > This is an announcement for a relatively new Tcl project: tcl-mmap > > Tcl-mmap is a Tcl interface to the POSIX mmap* system call. It provides > a Tcl package that allows Tcl scripts to: 1) Memory map files for > improved access efficiency; 2) Share memory between related processes; > 3) Easily implement cyclic persistent log files. > > * See the mmap(2) man page. > Great to see this and the other packages you made. Looking at the manpage it looks a bit misformatted before the usage example. Any specific reason to use GPL for this instead the usual Tcl/MIT/BSD style license used? Michael schlenk wrote: > On Sep 3, 11:48 am, Alexandros Stergiakis <alst...@gmail.com> wrote: >> This is an announcement for a relatively new Tcl project: tcl-mmap >> >> Tcl-mmap is a Tcl interface to the POSIX mmap* system call. It provides >> a Tcl package that...

adding events to tcl queue, or using variables and traces (C and TCL)
I'm writing simple testing framework for embedded application. The application is written on C language and runs on microchip PIC microcontroller normally. To test application I made the following: * hardware depended code was picked out from main source and written to separate source files (module_hal.c for example); * two build mode for program: for microchip PIC, using *_hal.c files dealing with real hardware, or for PC, where *_hal.c files contain hardware simulation code and bindings to TCL-commands. Then program was build for PC, I can using TCL commands change input signal states for simulated hardware, for example, or view output signal states. But I need some method to call tcl callback procedure when output signal changes state. I see two methods to achieve this: * map signal state to variable, and then use 'trace' command to bind tcl-scripts to state change events; * add new events to tcl event queue, as described here: http://wiki.tcl.tk/17195 Which method can be more preferable and why? In case if signal state changes too fast, and if I use variable trace, my callback will be called on every state change -- I think it is serious drawback of first method. With second method I can add only one event to queue, and add second only if first event is processed. But as I see, second method requires more complex code in C (now I wrote this code and see it as serious drawback too). May be exists some other methods to call tcl-callbacks on even...

about using tclapp wrap tcl and c program
Hi, all My program is developed with tcl/tk and c, in which I use Tk_Main() and Tcl_AppInit() function to customize my main code. in C function it will execute tcl script by Tcl_Eval(), and in Tcl script it will call the command procedure registered by Tcl_CreateCommand(). Now, I want to use tclapp to wrap my program to one starpack, could you tell me how to do this? Alternatively, the c code can be made one library, then load this library in tcl script. In this case, tclapp will add the base runtime envirnment of tcl/tk, but my c library depends on libtcl84.so and libtk84.so, need I add and wrap these two library repeatedly? Is any method to reduce the size of output. and what I need is starpack not starkit. Best Regards! Tony ...

question about compiling tcl/tk and c program
hello,everyone My ActiveTcl is installed in /home/myname/ActiveTcl. when I compile our tcl and c programs. I write a makefile and I set the -I and -L options as follows: -I~/ActiveTcl/include -L~/ActiveTcl/lib -ltcl8.4 -ltk8.4 after excute make command, the compile message as follows: /usr/bin/ld:cannot find -ltcl8.4 collect2: ld returned 1 exit status I code another small program, and use the follow command: gcc test.c -o test -I~ActiveTcl/include -I~/ActiveTcl/lib ~/ActiveTcl/lib/libtcl8.4.so it can compile successfully, but if use the follw command: gcc test.c -o test -I~ActiveTcl/include -I~/ActiveTcl/lib -ltcl8.4 it cannot find -ltcl8.4 what's wrong? I need your help. thank you very much. guo Hi Guo, guo writes: > gcc test.c -o test -I~ActiveTcl/include -I~/ActiveTcl/lib > ~/ActiveTcl/lib/libtcl8.4.so > it can compile successfully, but if use the follw command: > gcc test.c -o test -I~ActiveTcl/include -I~/ActiveTcl/lib > -ltcl8.4 > it cannot find -ltcl8.4 Short version: Use this instead: gcc -o test test.c \ -I$HOME/ActiveTcl/include \ -L$HOME/ActiveTcl/lib -ltcl8.4 Long version: "~" is a feature of the shell, just like "*" and "?". But "~" is only evaluated at the *start* of strings. So the shell will translate ~/something => $HOME/something => /home/guo/something (assuming that your home directory is "/home/guo"). But the shell will not touch -I~/Active...

TCL/TCL combined with Java/C/C++, Any Recommendations?
Hi, I have an application that I wrote in TCL/TK. It has to work with big files +5GB. The parsing performace is not where I would like and some of the data manipulations are taking considerable amount of time due to the data size. Therefore I am considering switching these parts of the code to Java, C or C++. While keepting the GUI and GUI supporting code in TCL/TK at this time. I am trying to figure out which language will be easier to merge with TCL in an application. For C I know that I can compile and generate a .so or .dll and create a TCL package and load it. I believe this is done with SWIG but I have not done it. In Java I saw some info on Jacl and TclBlend. The application will be "compiled" into a TCL "executable". I know I can compile my TCL code into Byte code to protect the IP. I am not sure about Java. Any recommendations or pointers will be greatly appreciated. Thanks in advance, Frank Frank <kranfg@gmail.com> writes: > Hi, > > I have an application that I wrote in TCL/TK. It has to work with big files +5GB. > > The parsing performace is not where I would like and some of the data manipulations are taking considerable amount of time due to the data size. > > Therefore I am considering switching these parts of the code to Java, C or C++. While keepting the GUI and GUI supporting code in TCL/TK at this time. > > I am trying to figure out which language will be easier to ...

about using tclapp wrap tcl/tk and c problem
Hi, all I know there are two methods to develop program using tcl/tk and c, the first method is by calling Tcl_Main, Tcl_AppInit to customize the main program and include tcl scripts; the other method is to make c library and then load the library in tcl script. Is there any method to use tclapp wrap the program developed by the first method? Could you tell me how to do this? now, I make my c program to a libmylib.so, and my tcl script will load it. libmylib.so depends on some other library, such as libtcl84.so and libtk84.so. now I wrap my tcl script and libmylib.so to a starpack. Tclapp will add base tcl runtime envirnment automatically, but, the libmylib.so depends on libtcl84.so and libtk84.so, need I add and wrap these library repeatedly? Is there any method to wrap my program but reduce the size of starpack? Best Regards! Tony O/H sunnyboyGuo@gmail.com έγραψε: > Hi, all > I know there are two methods to develop program using tcl/tk and c, the > first method is by calling Tcl_Main, Tcl_AppInit to customize the main > program and include tcl scripts; the other method is to make c library > and then load the library in tcl script. > Is there any method to use tclapp wrap the program developed by the > first method? Could you tell me how to do this? > > now, I make my c program to a libmylib.so, and my tcl script will load > it. libmylib.so depends on some other library, such as libtcl84.so and > libtk84.so. now I wrap my tcl script ...

How to use tcl to write a GUI to control a C program
I writed a programe (using C) to control two objects: keyboard A-------to make the small object rotate keyboard Y-------to make the large object rotate Now, I want to write a *graph user interface* using Tcl to control the objects.It should be combined with the C code. how can I do it? this is the C code section: #include <gl/glut.h> #include <stdlib.h> #include <stdio.h> static int year=0,day=0,month=0; void init(void) { glClearColor(0.0,0.0,0.0,0.0); glShadeModel(GL_FLAT); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0,1.0,0); glPushMatrix(); glRotatef((GLfloat)month,0.0,1.0,0.0); glutWireSphere(1.0,20,16);//draw sun glPopMatrix(); glPushMatrix(); glRotatef((GLfloat)year,0.0,1.0,0.0); glTranslatef(2.0,0.0,0.0); glRotatef((GLfloat)day,0.0,1.0,0.0); glColor3f(1.0,1.0,0); glutWireSphere(0.2,10,8);//draw planet glPopMatrix(); glutSwapBuffers(); } void reshape(int w,int h) { glViewport(0,0,(GLsizei) w,(GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0,(GLfloat) w/(GLfloat) h,1.0,20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0,0.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0); } void keyboard(unsigned char key,int x,int y) { switch (key){ case 't': month=(month+15)%360; glutPostRedisplay(); break; case 'd': day=(day+10)%360; glutPostRedisplay(); break; case 'D': day=(day-10)%360; glutPostRedisplay(); break; case 'y': year=(year...

Problem in calling c programs and compiling them in tcl/tk
Hello, I have been assigned to open a directory with c programs in it using tcl/tk. Later I am supposed to c ompile all those c programs in that directory one after another using tclk/tk. I am able to open the directory and read all the c files. But when it comes to compiling them am not able to do it at all. I have tried using exec gcc filename.c and later exec ./a.out filename.c. For example , if i take helloworld.c program & write above 2 steps , its showing the o/p as "helloworld" . But it's also saying like child process exited abnormally. Please can one suggest a simple command to execute c programs . All the fork and thread concepts are quite new and confusing to me. Isn't there any simple command in tcl from which i can call a c program and compile it ? I have spent nearly 4 days about this problem.But no idea at all. Please if anyone can solve this , reply soon , if possible with an example . I am supposed to complete it with in 1 day more. Thanks in advance On 11 nov, 11:23, vasavi.n...@gmail.com wrote: > Hello, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 I have been assigned to open a direct= ory with c > programs in it using tcl/tk. Later I am supposed to c ompile all those > c programs in that directory one after another using tclk/tk. > I am able to open the directory and read all the c files. But when it > comes to compiling them am not able to do it at all. I have tried > using exec gcc filename.c and l...

Interfacing Tcl/Tk GUI to existing C code
I've inherited some C code. I'm asked to create a Tcl/Tk GUI to run the C code on both Windows XP and Linux boxes. I'm assuming my Tcl/Tk GUI needs to detect Windows or Linux, then load my C code as a .dll or .so. Is this correct? Also, when I press a button on my Tck/Tk GUI, I'd like to say -command "hello()", and have it call the hello() function in my hello.dll. Can I just souce in the hello.dll and have the call to the hello() magically work? Thanks, Randy randy1200 <randy1200@yahoo.com> wrote: > I've inherited some C code. I'm asked to create a Tcl/Tk GUI > to run the C code on both Windows XP and Linux boxes. > I'm assuming my Tcl/Tk GUI needs to detect Windows or Linux, > then load my C code as a .dll or .so. Is this correct? No. Use [info sharedlibextension] if you are about loading DLL. But remember, that DLL you are loading into Tcl with load command, should have special interface layer written in C, which would translate C function to Tcl command. -- As I currently don't have a floppy drive in my computer, I'd like to make an `emergency cdrom' ;) -- Eugene Crosser <crosser@average.org> "randy1200" <randy1200@yahoo.com> writes: > I've inherited some C code. I'm asked to create a Tcl/Tk GUI to run > the C code on both Windows XP and Linux boxes. There are a number of ways of going about this... > I'm assuming my Tcl/Tk GUI needs to detec...

How to use TCL/TK in VC 6.0 application program?
I have a VC 6.0 application for a special need. now , I want to invoke TK command input interface and excute the command through VC application program's a window or a menu. i am a newbie ,please give me some suggestions, thank you! ...

Use TCL/TK to directly display c-generated jpg?
I have a C program that captures composite video images, converts them to jpg images, and stores the jpg images in files for later display. Is there any way for the C program, using TCL/TK, to display directly the jpg images without the overhead of saving the images in files? (Needless to say I am running in X-Windows, but the C program currently runs as a console app). Thanks, Dave Feustel dave wrote: > I have a C program that captures composite video images, converts them > to jpg images, and stores the jpg images in files for later display. > > Is there any way for the C program, using TCL/TK, to display directly > the jpg images without the overhead of saving the images in files? Look at [image create photo myimagename -data $imagedata ...] HTH, Gerry ...

Web resources about - Using Tcl/Tk as a user interface in a C program - comp.lang.tcl

Interface - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Wikipedia for iOS updated w/ redesigned interface, 3D Touch, Handoff & more
... released an update to its iOS app that adds a host of new features and capabilities. The latest version of the app offers a redesigned interface ...

Waze 4.0 unveiled with revamped user interface
... post, Waze has uploaded a video straight to YouTube to tell us what’s new. Basically, we are looking at a complete refresh to the user interface, ...

LibreOffice 5.1 reorganizes user interface, reduces start-up times
... 5.1 32-bit . It comes just under six months after version 5.0 debuted back in August yet unveils some major changes to the user interface as ...

Industrial IoT still needs humans and user interfaces
IoT is getting more automated, but not everything can be done by machines. An engineer who's been working with a system for decades has insights ...

Software brings your PC's entire interface to VR
Virtual reality faces numerous challenges, but one of the biggest is having to take your headset off whenever you need to run a conventional ...

LibreOffice 5.1 Offers Reorganized User Interface for Its Apps
LibreOffice 5.1, the latest iteration of the open-source office suite, adds new user interface elements. We examine highlights of the release. ...

AMD is supposedly planning a 32-core CPU with an eight-channel DDR4 interface
AMD may be planning a new 32-core server CPU once Zen launches but whether that's a good thing or not depends on whether its an Intel bunker ...

Hints Of Apple's Futuristic iPhone Interface Revealed
The US Patent Office has released a batch of patents assigned to Apple, and one of them details a new way of identifying yourself and allowing ...

Where is that sound coming from? Signal Interface’s acoustic imager will show you
... industrial site pinpoints sound coming from a passing truck as well as from equipment on the other side of a buildling. (Credit: Signal Interface ...

Resources last updated: 3/13/2016 8:21:16 PM