Hi, I am working on existing Perl/Tk package, quite large, and have a need for a text box that can be grayed out (e.g., until a checkbox is checked elsewhere). The existing code has a combo Label+Entry element which lines up everything nicely BUT I'm having trouble getting to the state of the Entry widget. Here is a boiled down test case:
use Tk; my $test1; my $var = "55"; $mw = MainWindow->new(); $FrameOpt = $mw -> Frame; my $exit_b = $mw->Button(-text => 'Exit', -command => sub { exit })->pack; $mw->Button(-text => "Toggle Textbox", -command => sub { my $state = $test1 -> Entry -> configure(-state); print "$state\n"; if ($state eq "disabled") { $test1 -> Entry -> configure(-state => 'normal') } else { $test1 -> Entry -> configure(-state => '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();
Output:
ARRAY(0x67e4b98)
As you can see, I'm having trouble isolating the state of the Entry widget inside the combo: $state is actually an array, and if I print the array I can see "normal" as one of the array elements, which is incorrect, so for sure it's not the correct state. Is there a way for me to get access to Entry -> state, or do I have to create some other combo widget with easier access? Thanks!

In reply to Changing state for gridded Entry? by cniggeler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.