in reply to Re^2: Changing state for gridded Entry?
in thread Changing state for gridded Entry?
Your problem was that $test1 did not have any "Entry" .. the entry is a child of $FrameOpt.use strict; use warnings; use Tk; my $test1; my $var = "55"; my $mw = MainWindow->new(); my $FrameOpt = $mw -> Frame; my $exit_b = $mw->Button(-text => 'Exit', -command => sub { exit })->pack; $mw->Button(-text => "Toggle Textbox", -command => sub { my ($entry) = grep { $_->class eq "Entry" } $FrameOpt->ch +ildren; $entry-> configure(-state => $entry->cget('-state') eq "d +isabled" ? 'normal' : 'disabled'); })->pack; sub GuiTextEntryLabelOnLeftCreate { my ($frame, %x_args) = @_; my $label; my $text = $x_args{'-text'}; delete $x_args{'-text'}; $label = $frame -> Label ( -text => $text, -foreground => "black" ) -> grid ( $frame -> Entry (%x_args) , -sticky => 'w' , -pady => 2 ); $label; } $test1 = GuiTextEntryLabelOnLeftCreate ( $FrameOpt , -text => "Test value" , -textvariable => \$var , -width => 6, -state => "disabled", -foreground => "gray", ); $FrameOpt->pack; MainLoop();
"These opinions are my own, though for a small fee they be yours too."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Changing state for gridded Entry?
by cniggeler (Sexton) on Jun 10, 2023 at 22:19 UTC | |
by NetWallah (Canon) on Jun 10, 2023 at 22:52 UTC | |
by cniggeler (Sexton) on Jun 11, 2023 at 11:43 UTC |