home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / tcl / 2166 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  2.4 KB

  1. Path: sparky!uunet!spool.mu.edu!yale.edu!jvnc.net!netnews.upenn.edu!bohr.physics.upenn.edu!raines
  2. From: raines@bohr.physics.upenn.edu (Paul Raines)
  3. Newsgroups: comp.lang.tcl
  4. Subject: Possible Map problem with Tk3.0
  5. Message-ID: <102654@netnews.upenn.edu>
  6. Date: 18 Dec 92 22:35:16 GMT
  7. Sender: news@netnews.upenn.edu
  8. Lines: 63
  9. Nntp-Posting-Host: bohr.physics.upenn.edu
  10.  
  11. I have tried running Jay Sekora's browser app under the new
  12. Tk3.0 wish put found that it mapped all children toplevel
  13. windows off the screen.  The problem seems to be with the
  14. binds to the Map event. The relevant code is below.  By commenting
  15. out the bind calls and explicity calling dowindowpos from windowpos,
  16. the window will show up with its left top corder in the middle.
  17. I couldn't find anything in the changes file that would seem to 
  18. relate to this difference.
  19.  
  20. ######################################################################
  21. # windowpos w - arrange to position window w near ctr of screen
  22. ######################################################################
  23.  
  24. proc windowpos { w } {
  25. # when this is called, the window hasn't been mapped yet, so
  26. # [winfo reqwidth $w] and [...reqheight...] would both report zero.
  27. # we set initial geometry off the screen, so the window won't appear
  28. # to jump when we change the geometry (it will initially be mapped off
  29. # the screen, but then `dowindowpos' will move it to the middle).
  30.  
  31.   set swidth [winfo screenwidth $w]
  32.   set sheight [winfo screenheight $w]
  33.  
  34. # first, put it off screen.  (actually, a corner of the titlebar will
  35. # show, even if I specify coordinates that should be further off the
  36. # screen.)
  37.  
  38.   wm geometry $w +${swidth}+${sheight}
  39.  
  40. # and arrange for `dowindowpos', which will actually put it in the middle,
  41. # to be called later.
  42.  
  43.   bind $w <Map> "dowindowpos $w"
  44. }
  45. #
  46. # dowindowpos w - used by windowpos
  47. #
  48. proc dowindowpos { w } {
  49.   set wwidth [winfo reqwidth $w]
  50.   set wheight [winfo reqheight $w]
  51.   set swidth [winfo screenwidth $w]
  52.   set sheight [winfo screenheight $w]
  53.  
  54. # centred horizontally; 1/3 down vertically
  55.  
  56.   set hpos [expr { ( $swidth - $wwidth ) / 2 }]
  57.   set vpos [expr { ( $sheight - $wheight ) / 3 }]
  58.  
  59.   wm geometry $w +${hpos}+${vpos}
  60.  
  61. # now unbind <Map>, so window doesn't jump around if it's unmapped (eg
  62. # iconified) and then remapped.
  63.  
  64.   bind $w <Map> {}
  65. }
  66.  
  67.  
  68.  
  69. -- 
  70. ____________________________________________________________________
  71. Paul Raines    raines@bohr.physics.upenn.edu    215-898-8832
  72. Dept. of Physics
  73. University of Pennsylvania
  74.