[PD] re-Tcl_LinkVar

carmen ix at replic.net
Thu Aug 25 21:08:04 CEST 2005

On Thu, Aug 25, 2005 at 06:42:54PM +0200, nico wrote:
> hi, how are you...
> >btw, if you want to run Tk, there would be a further difficulty
> >of having to start a separate thread for the Tcl event loop.
> i've made a starkit wich run pd with nogui and interact with pd using 
> [netsend] [netreceive] from pd parts and socket & socket -server from 
> tcl part
> but,
> tk does not update correctly data it receives via socket (i believe 
> it's because parsing proc invoke too many work)

my pd GUI works like this, at first my tries didnt work (was blocking the entire tk event loop). but eventually a combination of mathieu's emails and some tutorial circa tcl 7.3 worked..

you can get the code from
cvs -d :pserver:anonymous at cvs.sf.net:cvsroot/pure-data co -r devel_0_39 pd/src/pd*tk*
    heres the relevant server bits:

    variable pd_send
    if {[catch {set pd_send [socket localhost 4400]}]} {set pd_send -1} {puts "connected $pd_send"}
    catch {
    set pd_receive [socket -server ::pd::receive_conn 4401]
    proc receive_conn {s addr port} {
    fileevent $s readable [list ::pd::receive $s]
    fconfigure $s -buffering line -blocking 0
    puts "connection from $addr"
    proc receive {s} {
    set l [gets $s]
    if {[eof $s]} {
        close $s
	} else {
	    if {[catch {eval $l}]} {puts "error in: $l"}
    proc send {msg} {
    variable pd_send
    if {$pd_send ne -1} {
#       puts "sending: $msg"
	    puts $pd_send [concat $msg \;]
	        flush $pd_send

> so, i had i idea:
> i will make an external to link tcl variable with pd variable, without 
> using network.
> is it a bad idea?

if you get an in-process interpreter thread running as an external, please post!, id love to try..


More information about the Pd-list mailing list