Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Safe Interpreters

Status
Not open for further replies.

SSAnderson

Programmer
Joined
Oct 25, 2004
Messages
1
Location
US
I am having trouble getting my code to work. The GUI comes up but the fields are not updating. I think I am having a namespace issue. When the GUI comes up I telnet to 127.0.0.1 on the specified port and it logs in ok. When I type a command such as setColor yellow the GUI is not updated.

Code Here:
#!/usr/bin/wish

set parser [interp create -safe]

$parser eval {
proc setStatus {lbl} {
global statusValue
set statusValue $lbl
return $lbl
}

proc setColor {clr} {
global colorCanvas
$colorCanvas configure -bg $clr
return $clr
}
}

proc acceptConnect {cid addr port} {
fileevent $cid readable [list serverHandle $cid]
fconfigure $cid -buffering line
}

proc serverHandle {cid} {
global parser
if {[gets $cid request] < 0} {
close $cid
} else {
if {[catch {$parser eval $request} result] == 0} {
puts $cid $result
} else {
puts $cid [list error_result $result]
}
}
}

proc MakeGUI {} {
global colorCanvas

frame .ttl -relief raised -bd 2
label .ttl.lbl -text {Socket Parser Demo}
pack .ttl.lbl -side top -fill x -padx 40 -pady 10
pack .ttl -side top -fill x

set statusValue {(none)}
frame .wdgts -relief raised -bd 2
label .wdgts.slbl -text { status value:} -anchor e -width 20
entry .wdgts.ent -textvariable statusValue
grid .wdgts.slbl .wdgts.ent -sticky w

label .wdgts.clbl -text { Color Value:} -anchor e -width 20
set colorCanvas [canvas .wdgts.cvs -bg green -width 80 -height 16 -relief sunken -bd 2]
grid .wdgts.clbl .wdgts.cvs -sticky w
pack .wdgts -side top -fill x

button .xit -text {Dismiss} -command {exit}
pack .xit -side top -fill x
}

#Make the graphical user interface
MakeGUI

socket -server acceptConnect 9001
 
try to put an update statement at the end of your setColor.
 
Status
Not open for further replies.

Similar threads

Replies
1
Views
175

Part and Inventory Search

Sponsor

Back
Top