When you say you want it to be "in the background", do you mean that
it's stealing focus from the parent's window when it's created? Or
that the OS doesn't see it as a separate window?

As Nathan said, setting the Qt.Window flag on your Dialog/Widget
"should" promote it to its own Window, but I've only tried that in
Linux, so I don't know if this is any different on other platforms.

As a workaround, if you already have your Widget/Dialog class, you
could just make a QMainWindow class as a container, and add your
widget to it. I've done this before to re-use a QWidget in different
places, for example.

The example below is just a quick test, but it might give you an idea:

from PySide import QtCore, QtGui

class NewWindow(QtGui.QMainWindow):     # This is your MainWindow container
    def __init__(self, parent=None):
        super(NewWindow, self).__init__(parent)
        self.ownWidget = myWidget()    # Add your own widget to this window
        self.setCentralWidget(self.ownWidget)

class myWidget(QtGui.QDialog):
  def __init__(self, parent=None):
      super(myWidget, self).__init__(parent)
      self.setLayout(QtGui.QVBoxLayout())
      self.textlabel = QtGui.QLabel("some text")
      self.layout().addWidget(self.textlabel)

f = NewWindow(QtGui.QApplication.activeWindow())    # Create a
NewWindow instance as a child of Nuke
f.show()


Hope that helps.

Cheers,
Ivan

On Tue, Apr 3, 2012 at 1:52 PM, Brogan Ross <[email protected]> wrote:
> Nathan, that doesn't seem to work for me.  It still leaves the window on top
> of Nuke.
>
>
>
>
>
>
>
>
> On Tue, Apr 3, 2012 at 10:02 AM, Nathan Rusch <[email protected]>
> wrote:
>>
>> As I mentioned last night (and after testing to confirm that it works),
>> you set the Qt.Window flag on your Widget or Dialog (works for either).
>>
>>
>> from PySide import QtCore, QtGui
>>
>> class ExtraNukeWindow(QtGui.QDialog):
>>   def __init__(self, parent=QtGui.QApplication.activeWindow()):
>>       super(ExtraNukeWindow, self).__init__(parent)
>>       self.setWindowFlags(QtCore.Qt.Window)
>>
>> ExtraNukeWindow().show()
>>
>>
>> -Nathan
>>
>> -----Original Message----- From: Matthieu Cadet
>> Sent: Tuesday, April 03, 2012 9:02 AM
>>
>> To: Nuke Python discussion
>> Subject: Re: [Nuke-python] PySide window makes nuke crash on close
>>
>> @Johan, yep i've made made a mistake in my code sample, normally i
>> always set parent=None in the __init__\
>> but if i put like you say :
>>
>> def __init__(self,parent=QtGui.QApplication.activeWindow())
>>
>> Nuke don't crashs!!!! this is exactly what i want, but..., when set
>> the parent to Nuke,
>> the QDialog is now part of Nuke window, it's no more a separated
>> window ( is not listed
>> in the taskbar in Windows, and cannot be accessed by Alt+Tab switch )
>>
>> @Brogan, have you found any trick for doing what you want for your
>> custom PySide window?
>>
>> On Tue, Apr 3, 2012 at 7:05 AM, Nathan Rusch <[email protected]>
>> wrote:
>>>
>>> I’m not in front of any functional PySide installs at the moment, but if
>>> I
>>> remember correctly, you just need to call self.setWindowFlags(Qt.Window)
>>> in
>>> your QDialog’s __init__.
>>>
>>> -Nathan
>>>
>>>
>>> From: Brogan Ross
>>> Sent: Monday, April 02, 2012 9:44 PM
>>> To: Nuke Python discussion
>>> Subject: Re: [Nuke-python] PySide window makes nuke crash on close
>>>
>>> I'm in the same boat as, Matthieu.  I don't want the dialog to lock up
>>> Nuke.  I need it to just appear and be available if needed.
>>>
>>> I was doing things slightly different than Matthieu
>>>
>>> class TestWindow(QtGui.QWidget):
>>>    def __init__(self, parent=None):
>>>        QtGui.QWidget.__init__(self, parent)
>>>        self.setLayout(QtGui.QVBoxLayout())
>>>        self.line = QtGui.QLabel("some text")
>>>        self.layout()
>>>
>>> tw = TestWindow()
>>> tw.show()
>>>
>>>
>>> However, if I switch it over to QDialog and use activeWindow() as a Johan
>>> said, everything works fine, no crashing.  With one exception.  The
>>> window
>>> stays on top of Nuke and I want it to be able to be in the background.
>>>
>>> Sorry, I'm very new to PyQt/PySide.
>>>
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>>
>>>
>>> ________________________________
>>> _______________________________________________
>>> Nuke-python mailing list
>>> [email protected], http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>
>>>
>>> _______________________________________________
>>> Nuke-python mailing list
>>> [email protected], http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>
>>
>>
>>
>> --
>> Matthieu Cadet
>> Compositor Artist & TD,
>> nWave Digital
>> [email protected]
>> _______________________________________________
>> Nuke-python mailing list
>> [email protected], http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>> _______________________________________________
>> Nuke-python mailing list
>> [email protected], http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to