RE: how to disable a checkbutton?
ŠIŠKA Martin <[email protected]> Mon, 11 Sep 2006 21:06:36 +0200
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <C2DC7ACA00B9D941856DFBB0F57A776EAA3D6F@EXCHANGE-A.spordat-internal.sk> |
Hi Patrick,
You can use cget for getting actual state value of the checkbutton, and configure for setting it.
I hope, attached code example would help.
Kind regards,
Martin
--------------------------
use Tk;
use strict;
my $mw = new MainWindow;
my $checkButton = $mw->Checkbutton(-text => 'Checkbox')->pack;
my $button = $mw->Button(
-text => 'Disable checkbox',
-command => [ \&disable_checkbutton, $checkButton ]
)->pack;
$mw->MainLoop;
sub disable_checkbutton
{
my $checkButton = shift;
if($checkButton->cget('-state') eq 'disabled')
{
$checkButton->configure('-state' => 'normal');
}
else
{
$checkButton->configure('-state' => 'disabled');
}
}
________________________________
From: [email protected] [mailto:[email protected]] On Behalf Of Patrick David
Sent: Monday, September 11, 2006 7:10 PM
To: [email protected]
Subject: how to disable a checkbutton?
Hi,
I have just finished writing a Perl Tk application. I am using as part of an automatic treatment a checkbutton. When this one is checked, the refresh of all data is automatic and performed every N minutes, on the other hand when it is unchecked the refresh is stopped. I also have a button that allows me to perform a manual refresh and to cancel any automatic refresh in progress.
My question is about the disable state of this checkbutton. When I perform a manual refresh I would like the checkbutton to be cancelled and to return to its initial state which means unchecked. Except destroying the checkbutton widget and rebuilding it, does it exist a better way to perform what I would like to do?
Thanks in advance for your help
Patrick
________________________________
Yahoo! Messenger <http://us.rd.yahoo.com/mail/uk/taglines/default/messenger/*http://uk.messenger.yahoo.com> NEW - crystal clear PC to PC calling worldwide with voicemail <http://us.rd.yahoo.com/mail/uk/taglines/default/messenger/*http://uk.messenger.yahoo.com>
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk