A trivial problem with Tk, I am sure I am not doing it the right way

A trivial problem with Tk, I am sure I am not doing it the right way

Post by shya » Sat, 20 Jan 2007 13:56:41


Hi All

I am novice in Tk , so I have goofed up somewhere in my code ...Need
help

Heres my partial code snippet

# I define a global variable

set udrPath /udr

# and then I use it as textvariable for my entry widget
entry .bfmc.ud -text "/udr" -textvariable udrPath

#next to the entry widget, i have a button
button .bfmc.btud -text "Set" -command { MIBUpdate 0 $udrPath }

#So my idea is to trigger MIBUpdate procedure with the value of udrPath
whenever I click the button

#MIB Update is defined as

proc MIBUpdate { type value } {

global udp testStat udrPath


if { $testStat == "Stop" } {

puts $udp $type$value
}

if { $type == 0 } {

set udrPath $value

}

}

SO basically I enter a text in entry widget and it get set in the
udrPath variable
then when I click the button the MIBUpdate is called and the udrPath
value is sent to a udp socket inside the procedure.

This works fine in normal scenarios but there is a problem .as follows

if I enter the first time
/udr as the value inside entry it works well

but next time if i enter, say
/ab , then the value at remote udp socket is /abr instead of /ab , so
/ab overwrites /ud of /udr and becomes /abr

i.e the new value overwrites the previous value instead of scrapping it
totally.

I am sure there is a workaround but i am just not able to figure it
out.

Any help will be appreciated

thanks
in advance
 
 
 

A trivial problem with Tk, I am sure I am not doing it the right way

Post by bs » Sat, 20 Jan 2007 15:33:51


I'm not totally sure this is your problem, but why are you passing
udrPath to the proc, when you bring it into the MIBUpdate proc via
global? I would change the above to:

button .bfmc.btud -text "Set" -command [list MIBUpdate 0]

and then change your proc definition to be

proc MIBUpdate type { ...

and then use udrPath inside the proc instead of value.

 
 
 

A trivial problem with Tk, I am sure I am not doing it the right way

Post by shya » Sat, 20 Jan 2007 15:42:20

Thanks for the help

I found out that using [ .bfmc.ud get ] command i can get the correct
value without getting overwritten.

Also at the receiving udp entity I was not clearing the buffer earlier.

So this is not a tk problem but a problem with my idiotic mind

Sorry....