O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required