Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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"

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 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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2021-10-18 10:34 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (73 votes). Check out past polls.