[PyKDE] Proper way to show multiple windows?

Ingo Krabbe i.krabbe at dokom.net
Sun Jan 26 08:39:01 GMT 2003

On Sat, Jan 25, 2003 at 07:30:43AM -0800, star gazer wrote:
> Ken,
> I did the isModal() check and it returned 0 but using
> nw.show() does not leave the window up it just flashes
> away.  If I use nw.exec_loop() then the window stays
> up but I can't open another on.  This was so easy to
> do in wxpython.  It must be as easy here I just can't
> figure it out
> SG

Using a used to tool (wxpython) should always be simple, but it isn't
very hard to do a modal dialog in PyQt too !

That the window flashes is because you might create a local instance,
which is destroyed at function exit !!!

You have to store your window either in a global reference or put it
into a list of known windows, where you can delete it once you don't
need it anymore (that's what I do).

def open_modal_window(self):
	self.controlledServers.append( ServerControlOv( self,
					self, "Server Control", 0, 0) )
	x = len(self.controlledServers)-1

It is quite easy to use container facilities of python.  But most
applications will be happy with static allocation:

def open_modal_window(parent, control):
	global dialogA
	dialogA = ServerControlOv( parent, control,
		"Server Control", 0, 0) )

Anyway you have to use a variable that lives longer than your open

More information about the PyQt mailing list