Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Monitor dimensions

by bmann (Priest)
on Sep 02, 2005 at 19:28 UTC ( #488748=note: print w/ replies, xml ) Need Help??


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"


Comment on Re: Monitor dimensions
Select or Download Code
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 :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://488748]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (15)
As of 2014-04-17 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (449 votes), past polls