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

I am working on a project where I need to disable a Perl/Tk listbox widget. Most widgets have a -state option that I can set to disabled, but the Listbox widget doesn't seem to have this option. Can any monks out there enlighten me as to how I would go about disabling this widget?
  • Comment on disabling the Listbox widget in Perl/Tk

Replies are listed 'Best First'.
Re: disabling the Listbox widget in Perl/Tk
by tall_man (Parson) on Jun 11, 2003 at 15:00 UTC
    The way I have done it is to gray the box manually and disable all the bindings:
    $listbox->configure(-foreground => $grayout_color); # Disable all bindings. foreach my $seq ($listbox->bind()) { my $code = $listbox->bind($seq); # Store the $code somewhere... # if you want to re-enable later. $listbox->bind($seq, ""); }
Re: disabling the Listbox widget in Perl/Tk
by converter (Priest) on Jun 11, 2003 at 14:57 UTC

    The Tix-based Tk::TList widget supports the -state option. The TList widget class includes a lot more functionality than Listbox, but you should be able to use it with only minor modifications to your code.

Re: disabling the Listbox widget in Perl/Tk
by greenFox (Vicar) on Jun 12, 2003 at 02:41 UTC

    Possibly not what your looking for but the Tk::HList widget allows you to disable individual elements:

    $hlist->entryconfigure($entryPath, -state => 'disabled');

    --
    Life is a tale told by an idiot -- full of sound and fury, signifying nothing. William Shakespeare, Macbeth