Having more or less converted a lot of old Tk scripts over to Tkx I'm stuck for an port for the following function which repositions the window passed in as a parameter in the centre of the screen. I used to call this just before calling MainLoop, by which point Tk had obviously decided on the reqwidth and reqheight values.
sub CenterWindow
{
# Args: (0) window to center
# (1) [optional] desired width
# (2) [optional] desired height
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);
}
idletasks can be changed to Tkx::update() if necessary, but I am at a loss to find any obvious translation for the window specific parts of this old Tk routine. Tkx doesn't seem to have an equivalent for reqwidth, reqheight, screenwidth or screenheight retrieveable by cget().
Does the fact that I'm now using a grid layout in Tkx, rather than a pack layout in Tk have any relevance?
BTW I'm running ActivePerl 5.10 on Windows Vista if that makes any difference.