Hi All
I have written a code to enable/disable a text and entry widget on selection of a checkbutton, I was able to create it.However I have some queries
1. "m" variable is nothing but $w.bottom. I tried
proc lfEnableButtons {w} {
foreach child [winfo children $w] {
if {$child == "$m.text"} continue
if {$::test_suite_lindow} {
$child configure -state normal
} else {
$child configure -state disabled
}
}
}
This code didnt work , can anyone tell me what is the problem in this ?.
2. Earlier my code was like this ie call the checkbutton option first and then set the variable m , create text , bcos of which I got the error "m" unknown. I solved the problem by creating the text first and then the checkbutton option. I wanted to know , whether there is any other solution to overcome this?. I tried setting set m 0 , in the beginning of the code , later even after setting new value for "m", it was 0 always
checkbutton $w.cb2 -text {Download} -variable test_suite_lindow -command [list lfEnableButtons $w $m]
set m [frame $w.bottom]
text $m.text -yscrollcommand "$m.yscr set" -height 10 -width 60 -wrap none
scrollbar $m.yscr -orient vertical -command "$m.text yview"
pack $m.text -side left
pack $m.yscr -side right -fill y
pack $m
Thanking you in advance
Regards
Aman
#########CODE STARTS FROM HERE#####################################################
proc lfEnableButtons {w m} {
if {$::test_suite_lindow} {
$w.e1 configure -state normal
$w.e2 configure -state normal
$w.e3 configure -state normal
} else {
$w.e1 configure -state disabled
$w.e2 configure -state disabled
$w.e3 configure -state disabled
}
if {$::test_suite_lindow} {
$m.text configure -state normal
} else {
$m.text configure -state disabled
}
}
# entry1.tcl --
#
# This demonstration script creates several entry widgets without
# scrollbars.
#
# RCS: @(#) $Id: entry1.tcl,v 1.2 1998/09/14 18:23:28 stanton Exp $
set w .entry1
set entryvar 0
set test_suite_lindow 0
set test_suite_lindow1 0
catch {destroy $w}
toplevel $w
wm title $w "Entry Demonstration (no scrollbars)"
wm iconname $w "entry1"
label $w.msg -wraplength 5i -justify left -text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse button2 pressed."
pack $w.msg -side top
frame $w.buttons
pack $w.buttons -side bottom -fill x -pady 2m
button $w.buttons.dismiss -text Dismiss -command "destroy $w"
button $w.buttons.code -text "See Code" -command "showCode $w"
button $w.buttons.ok -text "OK" -command "showVars $w.dailog entryvar"
pack $w.buttons.dismiss $w.buttons.code $w.buttons.ok -side left -expand 1
set m [frame $w.bottom]
text $m.text -yscrollcommand "$m.yscr set" -height 10 -width 60 -wrap none
scrollbar $m.yscr -orient vertical -command "$m.text yview"
pack $m.text -side left
pack $m.yscr -side right -fill y
pack $m
entry $w.e1 -textvariable entryvar
entry $w.e2
entry $w.e3
checkbutton $w.cb2 -text {Download} -variable test_suite_lindow -command [list lfEnableButtons $w $m]
$m.text insert 1.0 "hi"
$m.text insert end "hi"
pack $w.e1 $w.e2 $w.e3 $w.cb2 -side top -pady 5 -padx 10 -fill x
$w.e1 insert 0 "Initial value"
$w.e2 insert end "This entry contains a long value, much too long "
$w.e2 insert end "to fit in the window at one time, so long in fact "
$w.e2 insert end "that you'll have to scan or scroll to see the end."
lfEnableButtons $w $m
#########CODE ENDS FROM HERE#####################################################
I have written a code to enable/disable a text and entry widget on selection of a checkbutton, I was able to create it.However I have some queries
1. "m" variable is nothing but $w.bottom. I tried
proc lfEnableButtons {w} {
foreach child [winfo children $w] {
if {$child == "$m.text"} continue
if {$::test_suite_lindow} {
$child configure -state normal
} else {
$child configure -state disabled
}
}
}
This code didnt work , can anyone tell me what is the problem in this ?.
2. Earlier my code was like this ie call the checkbutton option first and then set the variable m , create text , bcos of which I got the error "m" unknown. I solved the problem by creating the text first and then the checkbutton option. I wanted to know , whether there is any other solution to overcome this?. I tried setting set m 0 , in the beginning of the code , later even after setting new value for "m", it was 0 always
checkbutton $w.cb2 -text {Download} -variable test_suite_lindow -command [list lfEnableButtons $w $m]
set m [frame $w.bottom]
text $m.text -yscrollcommand "$m.yscr set" -height 10 -width 60 -wrap none
scrollbar $m.yscr -orient vertical -command "$m.text yview"
pack $m.text -side left
pack $m.yscr -side right -fill y
pack $m
Thanking you in advance
Regards
Aman
#########CODE STARTS FROM HERE#####################################################
proc lfEnableButtons {w m} {
if {$::test_suite_lindow} {
$w.e1 configure -state normal
$w.e2 configure -state normal
$w.e3 configure -state normal
} else {
$w.e1 configure -state disabled
$w.e2 configure -state disabled
$w.e3 configure -state disabled
}
if {$::test_suite_lindow} {
$m.text configure -state normal
} else {
$m.text configure -state disabled
}
}
# entry1.tcl --
#
# This demonstration script creates several entry widgets without
# scrollbars.
#
# RCS: @(#) $Id: entry1.tcl,v 1.2 1998/09/14 18:23:28 stanton Exp $
set w .entry1
set entryvar 0
set test_suite_lindow 0
set test_suite_lindow1 0
catch {destroy $w}
toplevel $w
wm title $w "Entry Demonstration (no scrollbars)"
wm iconname $w "entry1"
label $w.msg -wraplength 5i -justify left -text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse button2 pressed."
pack $w.msg -side top
frame $w.buttons
pack $w.buttons -side bottom -fill x -pady 2m
button $w.buttons.dismiss -text Dismiss -command "destroy $w"
button $w.buttons.code -text "See Code" -command "showCode $w"
button $w.buttons.ok -text "OK" -command "showVars $w.dailog entryvar"
pack $w.buttons.dismiss $w.buttons.code $w.buttons.ok -side left -expand 1
set m [frame $w.bottom]
text $m.text -yscrollcommand "$m.yscr set" -height 10 -width 60 -wrap none
scrollbar $m.yscr -orient vertical -command "$m.text yview"
pack $m.text -side left
pack $m.yscr -side right -fill y
pack $m
entry $w.e1 -textvariable entryvar
entry $w.e2
entry $w.e3
checkbutton $w.cb2 -text {Download} -variable test_suite_lindow -command [list lfEnableButtons $w $m]
$m.text insert 1.0 "hi"
$m.text insert end "hi"
pack $w.e1 $w.e2 $w.e3 $w.cb2 -side top -pady 5 -padx 10 -fill x
$w.e1 insert 0 "Initial value"
$w.e2 insert end "This entry contains a long value, much too long "
$w.e2 insert end "to fit in the window at one time, so long in fact "
$w.e2 insert end "that you'll have to scan or scroll to see the end."
lfEnableButtons $w $m
#########CODE ENDS FROM HERE#####################################################