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

Converting Screen Distances

If you prefer to use inches for screen distance but you want to print out pixels, you can use the pixels method to convert any valid screen distance string into a pixel value; for example:

$pixels = $widget->pixels("2i");    # What is 2 inches in pixels?
$pixels = $widget->pixels("2m");    # What is 2 millimeters in pixels?

The pixelsmethod rounds to the nearest whole pixel. You can get a fractional pixel result by using fpixels:

$pixels = $widget->fpixels("2i");    # What is 2 inches in pixels?
$pixels = $widget->fpixels("2m");    # What is 2 millimeters in pixels?

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