hm, every time I call a registered panel the first time, I find two objects with the respective ID e.g.:

<PySide.QtGui.QWidget object at 0x31c95f0> <type 'PySide.QtGui.QWidget'>

<__main__.TestWidget object at 0x31c9128> <class '__main__.TestWidget'>


If other instances are open, I am getting more QWidgets listed, e.g.:

<__main__.TestWidget object at 0x2338128> <class '__main__.TestWidget'>

<PySide.QtGui.QWidget object at 0x233ec20> <type 'PySide.QtGui.QWidget'> <PySide.QtGui.QWidget object at 0x2341f80> <type 'PySide.QtGui.QWidget'>


How can I now check which ones to close, because two of these belong to the panel I need to keep?!


Here is my test code which might be flawed:

http://pastebin.com/bp7w1BnP



I might not be seeing the trees for the woods here...




On 24/10/13 15:12, Frank Rueter wrote:
Cool, thanks Johan. That looks much simpler. Will give it a go as well...

On 24/10/13 15:10, Johan Aberg wrote:

If you make sure your widgets are using setObjectName(), you could possibly look up the widgets by name like so to make sure only on instance is running:

for widget in QtGui.QApplication.allWidgets()
    name = widget.objectName()
    if 'myWidgetName' in name:
        print name, type(widget)


I think the registered panel will be of class<class 'PyQt4.QtGui.QDialog'>

and the widget the PyCustom_Knob is pointing to<class 'PyQt4.QtGui.QWidget'>


As far as I can see, the panel and widget object will be destroyed when the panel is closed.


Johan

On 24/10/13 13:40, Frank Rueter wrote:
Hi all,


has anybody had success with enforcing only one instance of a PySide widget when it's registered as a panel?

My app writes data to disk upon certain events and loads that data again through the widget's constructor. So I need to make sure that only one instance is open at any given time, otherwise I'm running the risk of losing/corrupting that data.

Any ideas?

Cheers,
frank
_______________________________________________
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




_______________________________________________
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

_______________________________________________
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