I guess TK isn't that popular!

I hate to be the first to respond to my own thread, but here goes.

I stole borrowed some code from the Tk::Thumbnail module and came up with an immature solution. However, 1) I hate reinventing the wheel 2) My hack of the original code is not as elegant.

Seems like there should be an easier way to do this that utilizes the existing Tk::Thumbnail.. My thought is that I need to subclass this module.. Tk::Thumbnail::Select but am unsure how I would do this.. The whole TK arena is still confusing to me and I am not very OOP literate.

Ohhh... Saints of Perl Wisdom, please bless this humble monk with guidance

zzSPECTREz



CODE

use Tk; use TK::JPEG; use Tk::Photo; use strict; use warnings; sub mk_thumbnail { my $win = shift; my $img = shift; my $photo = $win->Photo( -file => $img ); my $thumb = $win->Photo; my $w = $photo->width; my $h = $photo->height; $w = ( $w /60 ); $h = ( $h /60 ); $thumb->copy( $photo, -subsample => ( $w, $h ) ); $photo->delete; return $thumb; } my $mw = MainWindow->new; my %images; my ($row, $col) = ( 0,0 ); foreach my $img ( <*.jpg>, <*.bmp> ) { my $thumb = mk_thumbnail ( $mw, $img ); $images{$img}=undef; my $frame = $mw->Labelframe( -text => $img)->grid( -row => $row, - +column => $col); my $lb1 = $frame->Label ( -image => $thumb)->pack; my $chk = $frame->Checkbutton ( -variable => \$images{$img} )->pac +k; $col++; if ($col == 4) { $col = 0; $row++; } } MainLoop; foreach my $k ( keys %images ){ print "$k:"; if ($images{$k} ) { print " selected.\n"; }else{ print " not selected.\n"; } }

In reply to Re: Tk::Thumbnail --> callback help by zzspectrez
in thread Tk::Thumbnail --> callback help by zzspectrez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.