UPDATE:

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

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); ...
Hello World!

With reference to the code below, if I comment out the

$mw -> minsize (qw(600 400));
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!

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;

In reply to Tk centering main window on screen. by spikey_wan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.