Just some comments to help improve your code. :-)

1. If you would put

use Tk::JPEG; use Tk::Png;
in your code, you could extend your filetypes easily, to include gif, jpg, and png.

2. It is a burden on the user to make 70 '40x40' files. It would be easy for you to allow any images in the images dir, and have your program make thumbnails automatically.

3. I didn't have the Splash modules installed, nor did I have 70 images handy, so I couldn't run this, but from looking at your code, I suspect there may be a memory gain when you run this. Have you watched the memory while running?

The reason I suspect this, is that you create a new Photo object in your button's click callback. These Photo objects will hang around in memory. If I was to do this, I would make photo-objects for each thumbnail just once at the start of the script, base64encode them, and stuff them into a hash. Then on your button clicks, just pull the right photo-object out of the hash. To see an example of this , see Tk ImageMap-color-zones

P.S. I've noticed that the most recent version of Imager causes a problem with that node's code. I'll figure it out an post a fix when I find the problem.


I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re: Tk: pair matching game by zentara
in thread Tk: pair matching game by sanPerl

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.