Hi,
I have a question on TK GUI. I have written a simple TK procedure to popup a window requesting the user to enter the MAC address of a device. It works perfectly. But I have to enter the MAC address every time I ran the test. I'm just wondering is there way to store those MAC address and display it whenever the tk procedure is called. Please let me know if there is a simple way to do it.
Here is my script,
proc CCX_Tag_ckPnt {} {
global _contrl
set dd 0
wm withdraw .
toplevel .tot
label .tot.l40 -text "Enter the Choke Point MAC address"
label .tot.l41 -text "MAC Address"
entry .tot.e41 -width 20 -relief sunken -bd 2 -textvariable ckMac
focus .tot.e41
button .tot.b10 -text "OK" -command {
set ck_mac [string trim $ckMac]
set status [IsPhysicalAddress $ck_mac]
if {$status == 0} {
tk_messageBox -message "Enter valid MAC \
address of chokepoint in format \r \
Example aa:bb:cc:dd:ee:ff "
set tst_status 0
}
if {$tst_status} {
set _contrl(ck_Mac) [string trim $ck_mac]
set dd 1
destroy .tot
}
}
grid .tot.l40 -row 0 -column 1 -sticky w
grid .tot.l41 -row 1 -column 0 -sticky e
grid .tot.e41 -row 1 -column 1 -sticky w
grid .tot.b10 -row 2 -column 1 -columnspan 2
vwait dd
return $_contrl(ck_Mac)
}
proc IsPhysicalAddress {address} {
if {[string length $address] > 17} {return 0}
if {$address == ""} {return 0}
if {![regexp {^[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]} $address]} {return 0}
return 1
}
I have a question on TK GUI. I have written a simple TK procedure to popup a window requesting the user to enter the MAC address of a device. It works perfectly. But I have to enter the MAC address every time I ran the test. I'm just wondering is there way to store those MAC address and display it whenever the tk procedure is called. Please let me know if there is a simple way to do it.
Here is my script,
proc CCX_Tag_ckPnt {} {
global _contrl
set dd 0
wm withdraw .
toplevel .tot
label .tot.l40 -text "Enter the Choke Point MAC address"
label .tot.l41 -text "MAC Address"
entry .tot.e41 -width 20 -relief sunken -bd 2 -textvariable ckMac
focus .tot.e41
button .tot.b10 -text "OK" -command {
set ck_mac [string trim $ckMac]
set status [IsPhysicalAddress $ck_mac]
if {$status == 0} {
tk_messageBox -message "Enter valid MAC \
address of chokepoint in format \r \
Example aa:bb:cc:dd:ee:ff "
set tst_status 0
}
if {$tst_status} {
set _contrl(ck_Mac) [string trim $ck_mac]
set dd 1
destroy .tot
}
}
grid .tot.l40 -row 0 -column 1 -sticky w
grid .tot.l41 -row 1 -column 0 -sticky e
grid .tot.e41 -row 1 -column 1 -sticky w
grid .tot.b10 -row 2 -column 1 -columnspan 2
vwait dd
return $_contrl(ck_Mac)
}
proc IsPhysicalAddress {address} {
if {[string length $address] > 17} {return 0}
if {$address == ""} {return 0}
if {![regexp {^[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]} $address]} {return 0}
return 1
}