in reply to Tk centering main window on screen.
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.
Edited by Chady -- closed <b> tag
|
|---|