Just for fun, here's a sort-of-listbox that changes item color and font
and is scrollable
constructed out of a pane and labels.
#!/usr/bin/perl
# http://perlmonks.org/?node_id=1212975
use strict;
use warnings;
use Tk;
use Tk::Pane;
my $mw = MainWindow->new;
$mw->geometry( '500x400+300+300' );
my @items;
my $selectedtext = '';
$mw->Button( -text => 'Exit', -command => sub { $mw->destroy },
)->pack( -side => 'bottom', -expand => 0, -fill => 'x' );
$mw->Label( -textvariable => \$selectedtext,
-width => 10,
-font => 'courier 30', -fg => 'navy',
)->pack( -side => 'right', -fill => 'y' );
my $pane = $mw->Scrolled(Pane => -scrollbars => 'oe',
-sticky => 'nsew',
)->pack(-fill => 'both', -expand => 1);
for my $text ( qw( one two three four five six seven eight nine ten )
+)
{
my $label = $pane->Label( -text => $text,
-fg => 'red', -font => 'courier 40',
)->pack(-fill => 'both', -expand => 1);
push @items, $label;
$label->bind('<ButtonRelease-1>' => sub {
$_->configure( -fg => 'red', -font => 'courier 40' ) for @items;
$selectedtext = $text;
$label->configure( -fg => 'green', -font => 'times 80' );
} );
}
MainLoop;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.