What do I need to to do the 2nd popup to get it to be centered in the main window?

Well you could always post this in the newsgroup comp.lang.perl.tk where the Tk internals experts hangout.

Personally, I think you are expecting too much from the popup widget. I think the big problem is that popup expects to be able to handle all the screen details in it's own way, and as soon as you try to add "defaults" like minsize, popup figures you are taking control, and expects you to calculate the position.

As to how you would do it..... just calculate it. Like:

sub CenterWindow { my($window, $width, $height) = @_; $window->idletasks; $width = $window->reqwidth unless $width; $height = $window->reqheight unless $height; my $x = int(($window->screenwidth / 2) - ($width / 2)); my $y = int(($window->screenheight / 2) - ($height / 2)); $window->geometry($width . "x" . $height . "+" . $x . "+" .$y); }

As far as I'm concerned that is EASIER than dealing with popup. I think popup was designed to display quick messages in view, it wasn't intended to be a "general purpose centering method".

If you want this badly enough, you could hack the Tk c code, to get it to do what you want, submit a patch, and it may be included in the next version. But I would ask about it on comp.lang.perl.tk first. As with most changes, it may break something else.


I'm not really a human, but I play one on earth. flash japh

Edited by Chady -- closed <b> tag


In reply to Re: Tk centering main window on screen. by zentara
in thread 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.