If by width of the screen you mean just the window itself, that's easy:
$c->pack(-expand => 1, -fill => 'both');
But if you mean, as I think you do, the width of the monitor screen, try using the methods vrootheight and vrootwidth as well:
#!/usr/bin/perl -w use Tk; use strict; my $mw = MainWindow->new; my $vh = $mw->vrootheight; my $vw = $mw->vrootwidth; # Note that the 'virtual window' height and width are $vh and $vw # respectively, so we use those dimensions for our Canvas height # and width, and let the Canvas expand and fill in both x and y # directions. # my $c = $mw->Canvas( -width => $vw, -height => $vh, -background =>'blue', -scrollregion =>[0, 0, 100, 100]); $c->pack(-expand => 1, -fill => 'both'); $c->createRectangle(100, 100, 150, 150, -fill => 'yellow'); MainLoop;
In reply to Re: How to adjust -tk program to the width of the screen?
by liverpole
in thread How to adjust -tk program to the width of the screen?
by tamaguchi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |