chessgui has asked for the wisdom of the Perl Monks concerning the following question:
This creates a quite sizeable main window in Tk. I would like to position this window exactly at screen coordinates (5,5) to be fully visible. The idea is to query the geometry of the main window, replace the (x,y) coordinates with a regular expression and then set it again with the correct geometry string. However before invoking the main loop $mw->geometry returns '1x1+0+0'. Unly updating the window (commenting out #$mw->update;) builds the geometry string in the correct way. This results in the main window appearing in the wrong place and then instantly being removed which causes an unfavourable flickering. (Iconifying before and deiconifying after does not help!) Any thoughts on how to get the correct dimensions of the window without displaying it?use Tk; my %font=(-font=>[-family=>'Courier New',-size=>10]); my %width=(-width=>120); my $mw=new MainWindow; my $entry=$mw->Entry( %width, -relief=>'groove', -borderwidth=>5, -textvariable=>\$entry_text, %font )->pack; $entry->focus; $entry->bind('<Key-Return>',\&enter); my $text=$mw->Text( %font, %width, -height=>43 )->pack; #$mw->update; my $geom=$mw->geometry; print "geom: $geom\n"; $geom=~s/\+\d+\+\d+/+5+5/; $mw->geometry($geom); MainLoop; ################ prints: geom: 1x1+0+0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MainWindow geometry problem (update?)
by BrowserUk (Patriarch) on Feb 10, 2012 at 05:45 UTC | |
by chessgui (Scribe) on Feb 10, 2012 at 05:55 UTC | |
|
Re: MainWindow geometry problem (update?)
by Khen1950fx (Canon) on Feb 10, 2012 at 07:39 UTC |