use Tk;
use strict;
use warnings;

# Die folgenden Pfade koennen von
# Version zu Version wechseln
# Unix/Linux:
# my $path = '/usr/X11R6/include/X11/cursorfont.h';
# Windows:
my $path = 'C:\Perl\site\lib\Tk\X11\cursorfont.h';

my @cursors;

my $mw = MainWindow->new(-background => 'black');
$mw->geometry("200x200");
$mw -> title('Test für Listbox');

$mw->Button(-text => "Exit",
            -command => sub { exit })
            ->pack(-side => "bottom",
                   -fill => "x");

# Listbox mit Scrollbar einrichten
my $scroll = $mw->Scrollbar;
my $lb = $mw->Listbox(-selectmode => 'single',
                     -yscrollcommand => [set => $scroll]);
$scroll->configure(-command => [yview => $lb]);

$scroll->pack(-side => 'right', -fill => 'y');
$lb->pack(-side => 'left', -fill => 'both');

## Datei einlesen,Cursornamen in der Listbox speichern
open (FH, "<", $path) || die "Oops: $!\n";
while (<FH>)
  { push(@cursors, $1) if (/\#define XC_(\w+) /); }
close(FH);
$lb->insert('end', sort @cursors);

# Cursor beim Anklicken der Zeile aendern
$lb->bind('<Button-1>',
  sub { $mw->configure(-cursor =>
                 $lb->get($lb->curselection)); });

MainLoop;