Skip to Main Content
Learning Perl/Tk
book

Learning Perl/Tk

by Nancy Walsh
January 1999
Beginner content levelBeginner
373 pages
9h 43m
English
O'Reilly Media, Inc.
Content preview from Learning Perl/Tk

16.7. Converting Screen Distances

If you prefer to use inches as a 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?
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl/Tk

Mastering Perl/Tk

Stephen Lidie, Nancy Walsh

Publisher Resources

ISBN: 1565923146Supplemental ContentCatalog PageErrata