Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-24 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found