home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeMastering Perl/TkSearch this book

13.8. 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 pixels method 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?


Library Navigation Links

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