[PYTHONMAC-SIG] Show/Hide Window?

James B. Wilkinson jimmy@cs.cofc.edu
Mon, 29 Sep 1997 20:44:40 -0400


MacPython just laughs at me when I try to invoke Win.ShowWindow.
Win.NewWindow works fine, and both NewWindow and ShowWindow are in the
Window Manager section of Inside Macintosh vol 1 (old), so I thought that
Win gets me to the Window Manager part of the toolbox.  Is this routine
just not implemented in MacPython, or is it in some other toolbox set?
Well, I finally noticed that everything gets imported into the Framework
twice, e.g. Win, Windows and QD, QuickDraw.  I even found them.  Windows
and QuickDraw are .py files that seem to have only constants in them, and
QD and Win have the puzzle-piece icons that mean extensions to me.  I guess
they have the executable code, but I have no idea how to find out what
routines are actually there.

Here's another puzzlement: I can't find any code in the Framework that
either hides a window or disposes of it, yet the windows disappear when I
click the close box.  When I try to trace it in the source, all I find is
bookkeeping stuff like setting the parent to None and getting the parent to
remove the window from its list of children.  I can't see how any of that
would make the window actually go away.  In the programming I did in C I
always had to be careful to do a DisposeWindow on any window I had done a
NewWindow for so that all the memory was given back to the heap.  Is that
being taken care of under the table here somehow?

What I'm trying to do is create windows that are not visible until a menu
item is selected.  Here's the code.  Is this the right way to do what I'm
after (modulo the ShowWindow problem)?  It seems to work (again, modulo the
ShowWindow problem).  I got this by stealing from ped and hacking on it.

class TAWindow(Window):

    def __init__(self, parent, width = 200, height = 100, name = 'TAWindow'):
        Window.__init__(self, parent)
        self.name = name
        r = windowbounds(width, height)
        w = Win.NewWindow(r, name, true, documentProc, -1, true, 0x55555555)
        #                           ^
        #                           ^
        #          I want a false here so the window is not visible right away.
        self.wid = w
        Qd.SetPort(w)
        Qd.TextFont(4)
        Qd.TextSize(12)
        self.root = self.MakeTree()

    def MakeTree(self):
        #application-dependent hook routine
        return root

    def open(self):
        Qd.SetPort(self.wid)   # Is this necessary here?
        #Win.ShowWindow(self.wid)# Why doesn't Python know about ShowWindow?
        self.do_postopen()


Thanks much.



-------------------------------------------------------------
Jimmy Wilkinson            | Perfessor of Computer Science
jimmy@cs.cofc.edu        | The College of Charleston
(803) 953-8160             | Charleston      SC        29424

If there is one word to describe me,
that word would have to be "profectionist".



_______________
PYTHONMAC-SIG  - SIG on Python for the Apple Macintosh

send messages to: pythonmac-sig@python.org
administrivia to: pythonmac-sig-request@python.org
_______________