Prev: How to detect the memory usage of tcl in an embeded environment (not with Purify)?
Next: channel driver question about timeouts
From: Keith on 2 Jul 2010 13:13 On 7/2/10 8:10 AM, in article 4f06af19-78df-428d-befe-87ff2cacc62a(a)z34g2000pro.googlegroups.com, "S-Y. Chen" <shenyeh_chen(a)hotmail.com> wrote: > Dear All, > > I am wondering if it possible to open a channel for a text widget, so > that I can do something like > > > puts $channel [format " *** hello there"] > > > Thanks for the help in advance > > > Regards > S-Y. Chen > > What type of channel a file, serial port or ? Read channel: set chan [open [file join $datadir scanx.csv] {RDONLY}] gets $chan sct set h 1 while { [ gets $chan line ] != -1 } { set line [split $line ,] if {[lindex $line 2] != {CNV} && [lindex $line 2] != {EDS}} \ {set sysnum($h) [lindex $line 0]; set stype($h) [lindex $line 2]; set sname($h) [lindex $line 3]} \ else {incr h -1} incr h 1 } close $chan Write channel: set chan [open [file join $datadir $filename] {WRONLY CREAT TRUNC}] puts $chan [big snip] close $chan --� Best Regards,�Keith http://home.comcast.net/~kilowattradio/
From: Uwe Klein on 2 Jul 2010 13:20 S-Y. Chen wrote: > On Jul 3, 12:24 am, Donald G Porter <d...(a)nist.gov> wrote: > >>S-Y. Chen wrote: >> >>>On Jul 2, 11:23 pm, Donald G Porter <d...(a)nist.gov> wrote: >>> >>>>S-Y. Chen wrote: >>>> >>>>>I am wondering if it possible to open a channel for a text widget,... >>>> >>>>See the Tk [console]. >> >>>>DGP >> >>>Actually.....I want to use "puts" to write something into the text >>>widget, just as writing to the file >> >>Yes, that's how the Tk [console] works. See it as an example of how >>to do what you are asking about. >> >>DGP > > > > well.....can anyone give a simple example for this ? I really have no > clue about how to do it...... > > Regards > S-Y. Chen > #!/usr/bin/wish set fd [ open "|cat - -" RDWR ] fconfigure $fd -buffering none -blocking 0 -encoding binary text .text ; pack .text fileevent $fd readable { puts -nonewline stderr hit: set cont [ read $fd ] puts stderr \"$cont\" .text insert end $cont } after 1000 {puts $fd "line 1 hallo dljflak"} after 2000 {puts $fd "line 2 hallo dljflak"} after 3000 {puts $fd "line 3 hallo dljflak"} after 4000 {puts $fd "line 4 hallo dljflak"}
From: Donald G Porter on 2 Jul 2010 13:28 Donald G Porter wrote: > S-Y. Chen wrote: >> On Jul 2, 11:23 pm, Donald G Porter <d...(a)nist.gov> wrote: >>> S-Y. Chen wrote: >>>> I am wondering if it possible to open a channel for a text widget,... >>> See the Tk [console]. >>> >>> DGP >> >> Actually.....I want to use "puts" to write something into the text >> widget, just as writing to the file > > Yes, that's how the Tk [console] works. See it as an example of how > to do what you are asking about. Having said that, it seems that with modern Tcl such things would be more easily done with [chan create]. DGP
From: Bruce on 2 Jul 2010 13:40 S-Y. Chen wrote: > On Jul 3, 12:24 am, Donald G Porter <d...(a)nist.gov> wrote: >> S-Y. Chen wrote: >>> On Jul 2, 11:23 pm, Donald G Porter <d...(a)nist.gov> wrote: >>>> S-Y. Chen wrote: >>>>> I am wondering if it possible to open a channel for a text widget,... >>>> See the Tk [console]. >>>> DGP >>> Actually.....I want to use "puts" to write something into the text >>> widget, just as writing to the file >> Yes, that's how the Tk [console] works. See it as an example of how >> to do what you are asking about. >> >> DGP > > > well.....can anyone give a simple example for this ? I really have no > clue about how to do it...... > That's what Don has been doing - look in the console.tcl file that is part of your Tcl installation it is a complete working example of doing that Bruce
From: Gerald W. Lester on 2 Jul 2010 14:24
Donald G Porter wrote: > Donald G Porter wrote: >>... > > Having said that, it seems that with modern Tcl such things would be > more easily done with [chan create]. When I saw this post I was thinking the same thing. :) -- +------------------------------------------------------------------------+ | Gerald W. Lester, President, KNG Consulting LLC | | Email: Gerald.Lester(a)kng-consulting.net | +------------------------------------------------------------------------+ |