Contrib/book-examples/f-16.10.pl
raw| 1 | #!/usr/local/bin/perl -w |
| 2 | |
| 3 | # |
| 4 | # Figure 16.8, p166 |
| 5 | # |
| 6 | |
| 7 | |
| 8 | use Tk; |
| 9 | |
| 10 | my $mw = MainWindow->new; |
| 11 | my $colors = $mw->Listbox->pack; |
| 12 | open (F, "/usr/lib/X11/rgb.txt") || die "Can't open rgb.txt"; |
| 13 | while (<F>) { |
| 14 | next if /^!/; |
| 15 | $colors->insert('end',(split)[3]); |
| 16 | } |
| 17 | $colors->bind('<Double-Button-1>', sub { |
| 18 | $colors->configure(-background => $colors->get($colors->curselection))}); |
| 19 | |
| 20 | MainLoop; |