Fellow monks,

I am in need of some explaination of focus in an entry widget.

I have written a program which I am almost completely happy with ( which is rare for me :] ) and I want to post it to craft, but it's got one small, but what I consider nagging, bug. It's a regular expressions practice program for beginners. You type in a regex, sample string, then you can see what it does.

My question is about the focus of the entry widget however. I'm trying to turn off the checkbox options if the user enters tr/// for their regex.

I've got the following code that doesn't seem to want to work right and I can't see why not.

Entry widget:

my $reg=$top->Entry(width=>30, -font=>12, -textvariable=>\$regex, -validatecommand=>\&setting, -validate=>'all', )->pack();

Checkbutton widget

my $i=$frame1->Checkbutton( -bg=>COLOR, -text=>'Ignore Case (i)', -command=>\&global, -activebackground=>COLOR, -onvalue=>'i', -offvalue=>' ', -variable=>\$i_status, -font=>'code12', -justify=>'left', -state=>$state, )->pack( -side=>'left', );

Subroutine

sub setting{ if (substr($regex,0,2)eq 'tr') {$state='disabled'} else {$state='active'}; }

What I'm curious about is, is it possible to assign -state via variable? I can't see why it wouldn't be.


In reply to Question regarding focus and Tk by Popcorn Dave

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.