Re: three minor questions

Dean Arnold <[email protected]> Thu, 07 Dec 2006 07:30:05 -0800
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
Anders Stegmann wrote:
> Hi!
> Three questions:
> 
> 1) Where can I find more bitmaps?

Do you mean for icons ? If so, some libraries
with lots of stuff from Tk are at:

http://www.satisoft.com/tcltk/icons/libraries.html

The contents are MIME64 encoded GIF images; see below
for a little script to extract them out to GIF images,
and build an HTML page to display them. But you'll need
to use Tk::Photo to display them, instead of Bitmap.

> 
> 3) What is the feature called, you can make appear
> when you point the mouse over i.e. a button (you know
> the yellow box with some text in it which typically
> explains what the button does)
> 

Tk::Balloon widget. Its a bit complicated to apply
(lots of position and timing options),
but works pretty well:

http://search.cpan.org/~ni-s/Tk-804.027/pod/Balloon.pod

HTH,
Dean Arnold
Presicient Corp.

use MIME::Base64;

use strict;
use warnings;

foreach my $file (@ARGV) {
     unless (-e "./icons/$file") {
         mkdir "./icons/$file" or die "Can't create ./icons/$file\n";
     }
     die "Can't open $file:$!"
         unless open(INF, "srcicons/$file");
     print " *** Starting $file...\n";

     my @icons = ();

     while (<INF>) {
         my @items = split /[\s:]/;
         my $name = shift @items;
         my $src = pop @items;
         my $gif = decode_base64($src);
         warn "Can't open $name.gif: $!" and next
             unless open(OUTF, ">./icons/$file/$name.gif");
         binmode OUTF;
         print "\t*** $name.gif\n";
         print OUTF $gif;
         close OUTF;
         push @icons, "./icons/$file/$name.gif";
     }

     close INF;

     open(HTMLF, ">$file.html");
     my $rows = int(sqrt(scalar @icons));
     my $cols = (scalar @icons)/$rows;
     $cols += 1
         if ($cols > int($cols));
     $cols = int($cols);

     print HTMLF "<html><body><table border=0>\n";

     while (scalar @icons) {
         print HTMLF "<tr>";

         for (1..$cols) {
             print HTMLF "<td><img src='", $icons[0], "' title='", shift @icons, "'></td>\n"
                 if (scalar @icons);
         }

         print HTMLF "</tr>\n";
     }
     print HTMLF "</table></body></html>\n";
     close HTMLF;
}
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk