If it possible get Pyblish window wrapper?

Hi,
I created a custom dialog window for Extractor and i wondering if it’s possible to get main window of Pyblish as parent parameter for a new dialog ?

Thank you

For Pyblish Lite, you’ll find that under pyblish_lite.app._window once the window is opened, and for Pyblish QML you’ll find that as the main window of the currently running QApplication, as it’s running within it’s own interpreter and Qt event loop.

So for pyblish_qml if i just run it from maya, i can not access it from the file with plugins, right ?

Normally, no; it’s basically a different application altogether, and it’d be like grabbing the window of another Maya.

However, there is something put in place recently to make the window a little more native to Maya that you might be able to use. Pinging @davidpower who was the one who wrote that mechanism. Do you know if that could that work, David?

Sorry for late reply, did not check my mailbox these days :cry:

With pyblish_qml, you could try setting these environment variables to true

os.environ["PYBLISH_QML_FOSTER"] = "1"
os.environ["PYBLISH_QML_FOSTER_FIXED"] = "1"  # Ensure QML window stay in Maya's main thread

But you will lost the real-time interact ability, since the QML window is now handling by Maya’s main thread (it was in subprocess), so the GUI will become laggy.

This is my extractor plugin in my test:

class MyDialog(QtWidgets.QDialog):

    def __init__(self, parent=None):
        super(MyDialog, self).__init__(parent)
        layout = QtWidgets.QVBoxLayout(self)
        buttons = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal, self)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)


class ExtractHero(pyblish.api.InstancePlugin):

    order = pyblish.api.ExtractorOrder

    def process(self, instance):
        if self.dialog():
            return True
        else:
            raise RuntimeError("Please press OK.")

    def get_window(self):
        import pyblish_qml.api

        server = pyblish_qml.api.current_server()
        return server.proxy.vessel  # The window spawned in Maya

    def dialog(self):
        parent = self.get_window()
        dialog = MyDialog(parent)
        result = dialog.exec_()

        return result == QtWidgets.QDialog.Accepted

I hope this helps :slight_smile:

Thanks ! That is really helpful !
I’m just wondering if it’s possible to attach pyblish_qml to maya without env variables
for example by setting some parameters with api ?

Great !

For environment var PYBLISH_QML_FOSTER, you could do…

pyblish_qml.show(foster=True)

But currently there’s no equivalent function arg for the environment var PYBLISH_QML_FOSTER_FIXED, didn’t think it would be use often, plus the Foster Mode is still an experimental feature (things might change in the feature release).

Thank you @sega_m for trying this feature out !!