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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radiobuttion value assign

Status
Not open for further replies.

mistkhan

Technical User
May 31, 2003
14
0
0
IN
Hi All

I have written a small proc to display a window with some radio button option. On selection of radio button, I wanted to store the value of the radio button variable in a different variable. I tried doing it , however its failing.
"
# Assigning the value of the Radio Button Variable
set g_dev_id $dev_id
puts $g_dev_id
"
Below is the source code.Can anybody help me in solving this issue.

Thanking you in advance
Regards
Aman

# Procedure for Select Device
proc selectdevice {w} {
#create toplevel
toplevel $w.selectdevice
set selectdev_w $w.selectdevice
wm geometry $selectdev_w 280x150+279+322
wm title $selectdev_w "Select Device"
wm transient $w.selectdevice .

#create the main frame
frame $selectdev_w.fra_main01 -borderwidth 2 -relief groove -height 140 -width 265
set fra_main01_seldev $selectdev_w.fra_main01

#create the titleframe for Device
TitleFrame $fra_main01_seldev.tit_device -foreground black -text Device
set tit_dev [$fra_main01_seldev.tit_device getframe]

#create the device id
radiobutton $tit_dev.rad_bid01 -disabledforeground #a3a3a3 -selectcolor #b03060 -text {Board ID 1} -variable dev_id -value 0
radiobutton $tit_dev.rad_bid02 -disabledforeground #a3a3a3 -selectcolor #b03060 -text {Board ID 2} -variable dev_id -value 1

# Assigning the value of the Radio Button Variable
set g_dev_id $dev_id
puts $g_dev_id


#place and show the device id
place $tit_dev.rad_bid01 -in $tit_dev -x 3 -y 0 -anchor nw -bordermode ignore
place $tit_dev.rad_bid02 -in $tit_dev -x 4 -y 35 -anchor nw -bordermode ignore
button $fra_main01_seldev.b_ok -disabledforeground #a3a3a3 -pady 0 -text OK -width 6
button $fra_main01_seldev.b_can -disabledforeground #a3a3a3 -pady 0 -text Cancel -width 6 -command [list destroy $selectdev_w]
place $fra_main01_seldev.tit_device -in $fra_main01_seldev -x 38 -y 24 -width 128 -height 87 -anchor nw -bordermode ignore
place $fra_main01_seldev.b_ok -in $fra_main01_seldev -x 185 -y 35 -anchor nw -bordermode ignore
place $fra_main01_seldev.b_can -in $fra_main01_seldev -x 185 -y 75 -anchor nw -bordermode ignore
###################
# SETTING GEOMETRY
###################
place $selectdev_w.fra_main01 -in $selectdev_w -x 6 -y 4 -width 265 -height 140 -anchor nw -bordermode ignore

# grab the focus only on Select device window
focus $selectdev_w
grab $selectdev_w
tkwait window $selectdev_w

}
 
Hi mistkhan,

try this, Instead of setting g_dev_id after the radiobutton description, add -command option to radiobutton.

your code should read like this.

################
radiobutton $tit_dev.rad_bid01 -disabledforeground #a3a3a3 -selectcolor #b03060 -text {Board ID 1} -variable dev_id -value 0 -command {set g_dev_id $dev_id
puts $g_dev_id
}
radiobutton $tit_dev.rad_bid02 -disabledforeground #a3a3a3 -selectcolor #b03060 -text {Board ID 2} -variable dev_id -value 1 -command {set g_dev_id $dev_id
puts $g_dev_id
}
##########



Pankaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top