home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!yale.edu!jvnc.net!netnews.upenn.edu!bohr.physics.upenn.edu!raines
- From: raines@bohr.physics.upenn.edu (Paul Raines)
- Newsgroups: comp.lang.tcl
- Subject: Possible Map problem with Tk3.0
- Message-ID: <102654@netnews.upenn.edu>
- Date: 18 Dec 92 22:35:16 GMT
- Sender: news@netnews.upenn.edu
- Lines: 63
- Nntp-Posting-Host: bohr.physics.upenn.edu
-
- I have tried running Jay Sekora's browser app under the new
- Tk3.0 wish put found that it mapped all children toplevel
- windows off the screen. The problem seems to be with the
- binds to the Map event. The relevant code is below. By commenting
- out the bind calls and explicity calling dowindowpos from windowpos,
- the window will show up with its left top corder in the middle.
- I couldn't find anything in the changes file that would seem to
- relate to this difference.
-
- ######################################################################
- # windowpos w - arrange to position window w near ctr of screen
- ######################################################################
-
- proc windowpos { w } {
- # when this is called, the window hasn't been mapped yet, so
- # [winfo reqwidth $w] and [...reqheight...] would both report zero.
- # we set initial geometry off the screen, so the window won't appear
- # to jump when we change the geometry (it will initially be mapped off
- # the screen, but then `dowindowpos' will move it to the middle).
-
- set swidth [winfo screenwidth $w]
- set sheight [winfo screenheight $w]
-
- # first, put it off screen. (actually, a corner of the titlebar will
- # show, even if I specify coordinates that should be further off the
- # screen.)
-
- wm geometry $w +${swidth}+${sheight}
-
- # and arrange for `dowindowpos', which will actually put it in the middle,
- # to be called later.
-
- bind $w <Map> "dowindowpos $w"
- }
- #
- # dowindowpos w - used by windowpos
- #
- proc dowindowpos { w } {
- set wwidth [winfo reqwidth $w]
- set wheight [winfo reqheight $w]
- set swidth [winfo screenwidth $w]
- set sheight [winfo screenheight $w]
-
- # centred horizontally; 1/3 down vertically
-
- set hpos [expr { ( $swidth - $wwidth ) / 2 }]
- set vpos [expr { ( $sheight - $wheight ) / 3 }]
-
- wm geometry $w +${hpos}+${vpos}
-
- # now unbind <Map>, so window doesn't jump around if it's unmapped (eg
- # iconified) and then remapped.
-
- bind $w <Map> {}
- }
-
-
-
- --
- ____________________________________________________________________
- Paul Raines raines@bohr.physics.upenn.edu 215-898-8832
- Dept. of Physics
- University of Pennsylvania
-