start page | rating of books | rating of authors | reviews | copyrights

Book HomeMastering Perl/TkSearch this book

17.2. Methods Common to All Image Types

Images are real objects; we need to create them and, when we're finished, destroy them; otherwise, their resources remain in use for the duration of program execution. For instance, if we create an image and assign it to a Label, then at some later time destroy the Label, like so:

my $l = $mw->Label(-image -> $image)
...
$l->destroy;

the image remains alive and ready for use again and again, even by multiple widgets simultaneously. If we want the image to go away, we must explicitly delete it:

$image->delete;

This applies to Bitmap, Pixmap, and Photo image types. Here are other methods available for any image type:

$image->cget(-option)
Returns the value of the image option -option

$image->configure(-option => value)
Configures the specified option

$image->delete
Deletes the image

$image->height
Returns the pixel height of the image

$image->type
Returns the image type of the image

$image->width
Returns the pixel width of the image



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.