From: Alex T. <al...@tw...> - 2005-11-18 23:00:55
|
kim...@ya... wrote: >Hi there, thanks for the reply. > >I am afraid that's not what I am looking for. I know >how to get the parent. My question was how do I >position the child window so that it opens up over the >parent. For instance, under Windows XP, if I am >using 2 monitors, if I don't do anything, the parent >window might end up on one side and the child window >will end up somewhere on the other side. > >What I am looking for is something like: > >a) Get the parents coordinate >b) Set the child coordinate to be some kind of a >function of the parent >c) Set up an event handler so that whenever the parent >window moves, change the child windows coordinate to >follow the parent. > >I know how to do these things in C - just don't know >how to use do it in PythonCard. > > > Both the parent and child window are just windows, so you can use any of the functions for a wxWindow. So, in the child's on_initialize(), you can do something like: self.Centre() which will centre the child window over its parent. Or you can do self.parent = self.GetParent() bx,by, dx, dy = self.parent.GetRect() self.Move( (bx, by+dy) ) to move the origin of the child to the bottom left of the parent. Or .... lots of things like that. In the parent window, you can add something like self.childWindow = model.childWindow(self, MyChild) and have handlers > def on_size(self, event): > print "size" > bx,by, dx, dy = self.GetRect() > self.childWindow.Move( (bx, by+dy) ) > pass > > def on_move(self, event): > print "move" > bx,by, dx, dy = self.GetRect() > self.childWindow.Move( (bx, by+dy) ) > pass of course, you ought to check that the child window exists, etc. :-) -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.362 / Virus Database: 267.13.2/170 - Release Date: 15/11/2005 |