Code Comments
Programming Forum and web based access to our favorite programming groups.
Hi,
Can anyone explain why position dosn't quite work right
after a window resize? There seems to be some negative
position values coming into play. Try the following 3
geometry statements in the resize sub. The '+20+20'
dosn't seem to hold position, but the '+40+40' does.
I'm guessing the new geometry request, somehow adds a -20
to the x and y values as it re-origins itself at 0,0.
So I seem to need to double the '+20+20' to '+40+40', to
maintain position.
Is that the deal?, that if you have a second geometry statement
in a program, the window always resets it's origin to 0,0 and
accumulates a negative position value?
Is it my fvwm2 Window Manager? I'm using Tk804.027.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $mw = MainWindow->new(-background => 'black');
$mw->geometry( '700x370+20+20' );
$mw->Button(-text =>'Resize',
-command => [\&resize]
)->pack();
$mw->Button(-text =>'Exit',
-command => sub{ Tk::exit },
)->pack();
MainLoop;
sub resize{
my $newwidth = 700;
my $newheight = 700;
#this one dosn't go to 0,0
# $mw->geometry($curwidth .'x'. $newheight );
#this one seems to go to 15,0
$mw->geometry($newwidth .'x'. $newheight . '+20+20' );
#this one comes close
# $mw->geometry($curwidth .'x'. $newheight . '+40+40' );
}
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Post Follow-up to this messageOn Sat, 04 Sep 2004 16:43:58 -0400, zentara <zentara@highstream.net>
wrote:
>Can anyone explain why position dosn't quite work right
>after a window resize? There seems to be some negative
Never mind, I have found a way to do it.
The mainwindow needs to be withdrawn before resizing and moving.
So this works fine:
sub resize{
my $newwidth = 700;
my $newheight = 700;
$mw->withdraw;
$mw->geometry($newwidth .'x'. $newheight . '+20+20' );
$mw->deiconify;
}
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.