Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

update() fails (??) on rare occasions on an iconified() window
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 !!!



Report this thread to moderator Post Follow-up to this message
Old Post
OdedDV
05-06-05 01:57 PM


Re: update() fails (??) on rare occasions on an iconified() window
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 nee
d
> 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 bli
nk
> 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");

Report this thread to moderator Post Follow-up to this message
Old Post
thundergnat
05-06-05 08:57 PM


Re: update() fails (??) on rare occasions on an iconified() window
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");



Report this thread to moderator Post Follow-up to this message
Old Post
OdedDV
05-15-05 12:13 AM


Re: update() fails (??) on rare occasions on an iconified() window
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


Report this thread to moderator Post Follow-up to this message
Old Post
Michael van Nieuwenhuize
05-15-05 12:13 AM


Re: update() fails (??) on rare occasions on an iconified() window
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
>



Report this thread to moderator Post Follow-up to this message
Old Post
OdedDV
05-15-05 12:13 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PerlTk archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:47 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.