[pygtk] Opening one window from another

Kurt Symanzik kurt at kbsymanzik.org
Fri May 11 07:52:31 WST 2007


Ing. Nestor Alonso Torres wrote:
> I have an application that launches a window. That window (let's call it 
> A) has a menu; there you can select one in many options.
> 
> I need that when the user selects an option, that window A closes, and 
> open another window B[1,2,3], according with the option selected in A.
> 
> I use to do that opening B from A, making A invisible, and then, from B, 
> destroying A. That doesn't seems to work with pyGTK...

If I am understanding what you want, here is how I replace one window 
with another.

 From window A (which calls itself main) I call the child passing in 
itself as a parameter, something like:

self.child = B(self.main)
self.main.hide()

Then from B (which refers to A as parent and itself as main) in 
__init__() I call:

self.posx, self.posy = self.parent.get_position()
self.main.move(self.posx, self.posy)
self.main.show()

Then when I am done with B and want to replace it with A I do this from B:

self.main.hide()
self.parent.show()
self.main.unrealize()

That is how I do it and it seems to work well.

Kurt

-- 
Kurt Symanzik
kurt at kbsymanzik.org
Skype id: ksymanzik
http://kbsymanzik.org


More information about the pygtk mailing list