One simple way to do this is to keep a reference to your UI instance on the 
class itself, and replace it each time the UI is instantiated. This has the 
added benefit of allowing the UI to be used non-modally for free, since there 
will always be a reference to it. You could use a global variable instead, but 
the class attribute is a bit more encapsulated.

To clean it up, you could either rely on automatic GC when the instance 
reference is replaced, or (depending on how the dialog actually functions 
internally) connect its .finished signal to a class method that clears the 
reference and maybe even calls its .deleteLater() method for good measure.

-Nathan



From: Fredrik Averpil 
Sent: Tuesday, June 07, 2016 11:34 AM
To: Nuke Python discussion 
Subject: [Nuke-python] Deleting existing PySide UI if it exists

Hi, 

I'm creating a simple UI in PySide. Before showing it, I'd like to make sure to 
delete any such already existing UI.

I've been having issues finding out how to achieve this.

Has anyone done this and if so, would you like to give some pointers?

Cheers,
Fredrik
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to