Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How to disable the buttons

by vr786 (Sexton)
on Nov 03, 2010 at 14:39 UTC ( [id://869245]=perlquestion: print w/replies, xml ) Need Help??

vr786 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I am designed some GUI, there i need to disable and enable the buttons and optionmenus , if i selects one in option-menu the second button should get active till then it should be disable, how can i do it........can you please help me, here is some code ....

#!/usr/bin/perl -w use Tk; my $mw = MainWindow->new(); $mw-> geometry("400x100"); $mw -> configure( -background => "cyan", -foreground => "lightblue" ); my ($var, $tvar); my $opt = $mw->Optionmenu( -background => "lightgreen", -options => [[jan=>1], [feb=>2], [mar=>3], [apr=>4]], -command => sub { print "got: ", shift, "\n" }, -variable => \$var, -textvariable => \$tvar )->pack; $opt->addOptions([may=>5],[jun=>6],[jul=>7],[aug=>8]); my $f = $mw->Frame(-relief=>'groove', -borderwidth => 2)->pack; $f->Label(-textvariable=>\$tvar)->pack(-side => 'left'); $f->Label(-text => " -> ")->pack(-side => 'left'); $f->Label(-textvariable=>\$var)->pack(-side => 'left'); $mw->Button(-text=>'Exit', -command=>sub{$mw->destroy})->pack; my $opt1 = $mw->Optionmenu( -background => "lightgreen", -options => [qw(test1 test2 test3)], -command => sub { print "got: ", shift, "\n" }, # -variable => \$var, #-textvariable => \$tvar )->pack; MainLoop;

Replies are listed 'Best First'.
Re: How to disable the buttons
by kcott (Archbishop) on Nov 03, 2010 at 15:11 UTC

    You change the state of the button as described in the Tk::Button documentation.

    -- Ken

      Can you please give me the example , i tried configuring buttons but i didn't get it....

        Unless you show what you've tried, it's impossible to explain where you might be going wrong.

        Here's an example direct from the source code of Tk::Button: $w->configure(-state => 'active');

        Here's one from the source code of Tk::Menubutton: $w->configure('-state','normal')

        As you can see, there's nothing special here.

        -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://869245]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-16 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found