Home > Archive > PerlTk > May 2005 > update() fails (??) on rare occasions on an iconified() window
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
update() fails (??) on rare occasions on an iconified() window
|
|
| OdedDV 2005-05-06, 8:57 am |
| Hello,
I'm having a new MainWindow which gets iconified right after creation.
The window is built (labels, menus, entries, etc.) and at some point I need
to get its actual dimensions.
I use:
$mw -> update();
$w = $mw -> width();
$h = $mw -> height();
and then continue building some more stuff and eventually deiconifying the
window.
In most (99%) of the cases I launch this application all works perfectly.
However, in rare occasions, it happens that $w above gets the value 1 and $h
gets the value 0.
This is obviously wrong and ruins the building activities following this.
My current workaround (as ugly as it looks) is:
$mw -> update();
$w = $mw -> width();
$h = $mw -> height();
if ($w == 1 && $h == 0) {
$mw -> deiconify();
$mw -> update();
$w = $mw -> width();
$h = $mw -> height();
$mw -> iconify();
}
With this all works ok, but on those rare occasions, I get a temporary blink
of the window because of the deiconifying and the iconifying right
afterwards... Not a big deal, but I'd like to try and avoid it.
Can anyone suggest me better ideas ?
Thanks all in advance !!!
| |
| thundergnat 2005-05-06, 3:57 pm |
| OdedDV wrote:
> Hello,
>
> I'm having a new MainWindow which gets iconified right after creation.
> The window is built (labels, menus, entries, etc.) and at some point I need
> to get its actual dimensions.
> I use:
>
> $mw -> update();
> $w = $mw -> width();
> $h = $mw -> height();
>
> and then continue building some more stuff and eventually deiconifying the
> window.
>
> In most (99%) of the cases I launch this application all works perfectly.
> However, in rare occasions, it happens that $w above gets the value 1 and $h
> gets the value 0.
> This is obviously wrong and ruins the building activities following this.
>
> My current workaround (as ugly as it looks) is:
>
> $mw -> update();
> $w = $mw -> width();
> $h = $mw -> height();
> if ($w == 1 && $h == 0) {
> $mw -> deiconify();
> $mw -> update();
> $w = $mw -> width();
> $h = $mw -> height();
> $mw -> iconify();
> }
>
> With this all works ok, but on those rare occasions, I get a temporary blink
> of the window because of the deiconifying and the iconifying right
> afterwards... Not a big deal, but I'd like to try and avoid it.
>
Does your MainWindow end up at the same final size each time the script is
run? If so, just set the geometry to be whatever you want it to be. You can
do it while it is iconified.
my $mw = MainWindow->new;
$mw -> iconify();
my ($desired_width, $desired_height) = (500, 250); # or whatever
my (undef, undef, $x_pos, $y_pos) = split /[x+]/, $mw->geometry;
$mw->geometry($desired_width.'x'.$desired_height."+$x_pos+$y_pos");
| |
| OdedDV 2005-05-14, 7:13 pm |
| Not really... The Canvas is built dynamically according to a config file.
I guess I'll have to stick to my workaround then...
Thanks for the help,
Oded
"thundergnat" <thundergnat@hotmail.com> wrote in message
news:SOednaGNOIwr8ObfRVn-gA@rcn.net...
> OdedDV wrote:
>
> Does your MainWindow end up at the same final size each time the script is
> run? If so, just set the geometry to be whatever you want it to be. You
> can
> do it while it is iconified.
>
>
> my $mw = MainWindow->new;
>
> $mw -> iconify();
>
> my ($desired_width, $desired_height) = (500, 250); # or whatever
>
> my (undef, undef, $x_pos, $y_pos) = split /[x+]/, $mw->geometry;
>
> $mw->geometry($desired_width.'x'.$desired_height."+$x_pos+$y_pos");
| |
| Michael van Nieuwenhuize 2005-05-14, 7:13 pm |
| Have you tried using the withdraw method. This will pull the mainwindow
from the screen, doesn't create the icon.
$mw= MainWindow->new()
$mw->withdraw()
Build all the widgets you need before the update and geometry fetches.
Then do your update.
$mw->update
$mw->width
$mw->heigth
Continue building your dynamic widgets based on geometry fetched.
Once all your widgets are populated raise the mainwindow.
$mw->deiconify
$mw->raise
According to perldoc Tk::Mw the deiconify method is required to
bring up the mainwindow. Also see Mptk page 233 if you have it.
I have used this in the past on a our Solaris boxes, it also works
on our linux farm. Not sure about other Oses.
Regards,
Mike
| |
| OdedDV 2005-05-14, 7:13 pm |
| I was trying to use withdraw() instead of iconify(). I get erroneous window
build-up... I have to stick to iconify()...
BTW, on Solaris I have a rather old Perl version (5.003) which behaves
properly :) The issue is with the newer versions (5.6.1 and 5.8.3).
Thanks,
Oded
"Michael van Nieuwenhuize" <michaelv@qualcomm.com> wrote in message
news:1115923216.330021.171800@o13g2000cwo.googlegroups.com...
> Have you tried using the withdraw method. This will pull the mainwindow
> from the screen, doesn't create the icon.
>
> $mw= MainWindow->new()
> $mw->withdraw()
>
> Build all the widgets you need before the update and geometry fetches.
> Then do your update.
>
> $mw->update
> $mw->width
> $mw->heigth
>
> Continue building your dynamic widgets based on geometry fetched.
> Once all your widgets are populated raise the mainwindow.
>
> $mw->deiconify
> $mw->raise
>
> According to perldoc Tk::Mw the deiconify method is required to
> bring up the mainwindow. Also see Mptk page 233 if you have it.
>
> I have used this in the past on a our Solaris boxes, it also works
> on our linux farm. Not sure about other Oses.
>
> Regards,
>
> Mike
>
|
|
|
|
|