spikey_wan has asked for the wisdom of the Perl Monks concerning the following question:
I asked this question in another forum, and got the answer from Jack D. It appears that there is a bug in the Popup method, and it only uses the requested size. This should be fixed in the next version, but you can fix it yourself by adding the following three lines (with #JD#) to the Popup subroutine of C:\Perl\site\lib\Tk\Wm.pm and C:\Perl\site\lib\auto\Tk\Wm\Popup.al
Hello World!sub Popup { my $w = shift; $w->configure(@_) if @_; $w->idletasks; my ($mw,$mh) = ($w->reqwidth,$w->reqheight); my ($minwidth,$minheight) = $w->minsize; #JD# $mw = $minwidth if (defined $minwidth and $minwidth > $mw); #JD# $mh = $minheight if (defined $minheight and $minheight >$mh); #JD# my ($rx,$ry,$rw,$rh) = (0,0,0,0); ...
With reference to the code below, if I comment out the
line, my main window appears centered in the centre of the screen. With that line in, some part of the main window (I don't know what) is positioned relative to the centre of the screen. Can anyone tell me what I need to do to get it to appear in the centre of the screen after issuing a minsize command? I've tried every combination and order I can think of!$mw -> minsize (qw(600 400));
Thanks,
Spike.
use strict; use warnings; use Tk; my $mw = MainWindow -> new; $mw -> minsize (qw(600 400)); $mw -> withdraw; for (1..10) { my $button = $mw -> Label (-text => "Label $_") -> pack; } $mw -> update; $mw -> idletasks; $mw -> Popup( -overanchor => 'c', -popanchor => 'c', ); MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk centering main window on screen.
by gri6507 (Deacon) on May 27, 2004 at 15:36 UTC | |
by spikey_wan (Scribe) on May 27, 2004 at 15:40 UTC | |
|
Re: Tk centering main window on screen.
by zentara (Cardinal) on May 27, 2004 at 17:08 UTC | |
by spikey_wan (Scribe) on May 28, 2004 at 09:49 UTC | |
|
Re: Tk centering main window on screen.
by eserte (Deacon) on Jun 01, 2004 at 17:46 UTC | |
|
Re: Tk centering main window on screen.
by zentara (Cardinal) on May 28, 2004 at 15:03 UTC |