Hello All,
I have two questions reguarding Tk::ListBox.
Issue:
I create a list box with "-state->disabled" but it does not show the items in the list box
Questions
1. How do I create a list box,in a disabled state, so that the items in the listbox are shown but the user is not able to select anything in the list?
2. When I click the checkbox, how do I enable the listbox so that the user is now able to select items from the list?
Thanks for your help and assistance in advance
Gary
use strict;
use Tk;
my $lst_properties;
my $chk_options;
my $chkoptions;
my $MainWindow;
&maingui;
sub maingui {
$MainWindow = MainWindow->new(-title=>'Listbox');
$chk_options = $MainWindow -> Checkbutton ( -anchor=>'nw',
-justify=>'left',-relief=>'flat',
-indicatoron=>1,-text=>'Additional Criteria',
-variable=>\$chkoptions, -state=>'normal',
-command=>\&Additional_Criteria
) -> grid(-row=>1,-column=>0,-pady=>5);
$lst_properties= $MainWindow -> Scrolled ( 'Listbox',
-selectmode=>'single', -relief=>'sunken',
-scrollbars=>'osoe',-width=>50,-state=>'disabled');
$lst_properties -> insert('end',"People","Animals","Aliens","Meat"
+,
"Fruit","Vegies","Dairy","Pultry",
);
$lst_properties -> grid(-row=>5,-column=>1,-pady=>3);
MainLoop;
}
sub Additional_Criteria
{
#code her to test if check box is selected or not
if ($chkoptions) {
print "Enable\n";
#Code here to ENABLE ListBox
}
else {
print "Disable\n";
#Code here to DISABLE ListBox
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.