http://qs321.pair.com?node_id=488748


in reply to Monitor dimensions

The aptly named screenwidth and screenheight methods of the MainWindow will give you that info. They are documented in Tk::Wm. While the documentation for Tk is good, it takes some searching to find relevant info. I own a copy of "Mastering Perl/Tk", and it's a good reference to have on hand.

Here's a quick example:

#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new; $mw->Label( -text => $mw->screenheight . " x ". $mw->screenwidth )->p +ack; MainLoop;
On this computer, it gives me "1280 x 1024"

Replies are listed 'Best First'.
Re^2: Monitor dimensions
by biochris (Beadle) on Sep 02, 2005 at 19:37 UTC
    Thank you very much. I tried using just Internet resources, but it looks like I have to get the resource book ($$). I really appreciate your response though :)
      To be honest, I didn't use the book this time. I had a dim recollection of "screenheight" so I grepped the Tk directory and found Wm.pm and Wm.pod.

      If you're looking at buying the book, I got mine with the Perl CD Bookshelf v3 - includes paper Perl in a nutshell and digital "Programming Perl" (3rd edition), "Perl Cookbook", "Mastering Perl/Tk", "Perl and LWP", and "Perl and XML", all for about the price of two books. I'd check ebay.

      The fourth version is available now, but it drops the LWP, Tk and XML books in favor of merlyn's latest book and "Mastering Regular Expressions". It also has a newer version of the cookbook.

      Good luck!

      Update: A quick search on ebay shows several copies for under $20 US, including shipping.

        Thanks again, you sure know how to cheer someone up and give some good advice. I really get encouraged when I come across helpful monks like you :)