Popcorn Dave has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question regarding focus and Tk
by Chmrr (Vicar) on May 02, 2002 at 21:14 UTC | |
|
Re: Question regarding focus and Tk
by bmcatt (Friar) on May 02, 2002 at 20:00 UTC |