Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TclTK help - how to puts the contents of a text widget



In a quick cut and past I cut of  the file following the shell redirect
">".  Here is some working code (just change the path the wish):  
The "exec" command in tcl basically escapes wish to run shell commands.
This code puts the contents of a variable in a file allowing to you "save"
it.  I'm not sure if this what you are trying to do, Christoph, but hope
this is helpful.   Note ">>" will append ">" will overwrite existing files.

-Jason

#!/usr/local/bin/wish -f

frame .middle -relief flat -borderwidth 2
label .middle.text -text "Paste Logs here"
entry .middle.elogs -relief sunken -width 60 -textvariable logs 
pack  .middle.text -side top
pack  .middle.elogs -side left
pack  .middle 

frame  .bottom -relief flat -borderwidth 2
button .bottom.b1 -text "Examine logs" 
pack .bottom.b1 -side left -padx 1m -pady 1m
pack .bottom.b2 -side left -padx 1m -pady 1m
pack .bottom

bind .bottom.b1 <Button-1> {
        exec echo "$logs" > /tmp/tcl.out
        exit
}



At 12:31 PM 11/30/00 -0500, John Chambers wrote:
>Jason Nelson <jtnelson at genuity.net> wrote:
>| A snippet of some tck/tk code that I have that does the trick:
>|
>| entry .middle.elogs -relief sunken -width 60 -textvariable logs
>|
>| bind .bottom.b1 <Button-1> {
>|       exec echo "$logs" >
>| }
>
>Hmmm ...  Funny code, but there are things about tcl that I
>haven't  yet learned, so I stuffed it into a file and added
>the obvious frame and button and pack commands.  When I ran
>it, sure enough, I got a popup error window that told me:
>
>
>can't specify ">" as last word in command
>    while executing
>"exec echo "$logs" >"
>    (command bound to event)
>
>
>So it's not valid tcl after all.  Any more clues that might
>help  us  construct  something that works?  I don't offhand
>know of an answer to the question.  If there is a way to do
>it,  I'd  like to add a working example to my tcl/examples/
>directory.
>-
>Subcription/unsubscription/info requests: send e-mail with
>"subscribe", "unsubscribe", or "info" on the first line of the
>message body to discuss-request at blu.org (Subject line is ignored).
> 
______________________________________________________ 
VPN & Internet Security Services 
Genuity Inc. - Formerly BBN 
(781) 262-6126 office
-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org