RE: how to disable a checkbutton?

IvorW <[email protected]> Tue, 12 Sep 2006 06:20:20 -0400
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
> -----Original Message-----
> From: Patrick David
> Sent: 11 September 2006 18:10
> 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?

Besides destroying and recreating, there are other options:

* Disabling (greying out). 

$widget->configure ( -state => 'disabled' );

This will stop the user checking or unchecking. The on or off state is 
controlled by the checkbutton's variable; set this to a true or false value to 
change the state from inside the application. You can still do this if the
button is disabled.

* Unpacking (hiding)

$widget->packForget

This assumes you are using pack as your geometry manager. When you want the
button to reappear, call pack on it again.

Hope this helps,

Ivor.
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk