Hi,
Thought it would be nice now we have QT UI for studio’s to build their own UI’s as both standalone and with a minimum amount of change, allow them to be ‘hosted’ / tied into the Deadline environment when required by a studio.
So, I’m trying to tie a basic pyQT UI script into Deadline’s QApplication as it’s parent but not having much luck. What if Deadline in it’s own shipping version of Python also included pyQT and PySide site-packages in the future?
[code]import os, sys
from PyQt4 import QtCore, QtGui
from Deadline.Scripting import *
class SampleDialog(QtGui.QDialog):
def init(self, parent):
super(SampleDialog, self).init(parent)
self.setWindowTitle(‘Test QT QDialog in Deadline’)
self.resize(400, 200)
class MainWindow(QtGui.QMainWindow):
def init(self, parent = None):
super(MainWindow, self).init(parent)
self.setWindowTitle(‘Test QT QWindow inside of Deadline’)
self.resize(600, 400)
# create the menu
file_menu = self.menuBar().addMenu('File')
edit_menu = self.menuBar().addMenu('Edit')
debug_menu = self.menuBar().addMenu('Debug')
# create the menu actions
exec_act = debug_menu.addAction('Exec Dialog')
show_act = debug_menu.addAction('Show Dialog')
count_act = debug_menu.addAction('Show Count')
# create the connections
exec_act.triggered.connect( self.execDialog )
show_act.triggered.connect( self.showDialog )
count_act.triggered.connect( self.showCount )
def execDialog(self):
dlg = SampleDialog(self)
dlg.exec_()
def showDialog(self):
dlg = SampleDialog(self)
dlg.show()
def showCount(self):
count = len(self.findChildren(QtGui.QDialog))
QtGui.QMessageBox.information(self, 'Dialog Count', str(count))
def main( *args ):
window = MainWindow()
window.show()
QApplication.exec_()[/code]
I get this error:
2013-09-17 10:49:02: Traceback (most recent call last):
2013-09-17 10:49:02: File "DeadlineUI\UI\Commands\ScriptCommands.py", line 87, in InnerExecute
2013-09-17 10:49:02: Exception: Python Error: NameError : global name 'QApplication' is not defined (Python.Runtime.PythonException)
2013-09-17 10:49:02: Stack Trace:
2013-09-17 10:49:02: [' File "none", line 52, in __main__\n']
2013-09-17 10:49:02:
2013-09-17 10:49:02: at FranticX.Scripting.PythonNetScriptEngine.a (System.Exception A_0) [0x00000] in <filename unknown>:0
2013-09-17 10:49:02: at FranticX.Scripting.PythonNetScriptEngine.CallFunction (System.String functionName, Python.Runtime.PyObject[] args) [0x00000] in <filename unknown>:0
2013-09-17 10:49:02: at Deadline.Scripting.DeadlineScriptEngine.CallFunction (System.String functionName, Python.Runtime.PyObject[] args) [0x00000] in <filename unknown>:0
2013-09-17 10:49:02: at Deadline.Scripting.DeadlineScriptManager.CallFunction (System.String scopeName, System.String functionName) [0x00000] in <filename unknown>:0
2013-09-17 10:49:02: at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
2013-09-17 10:49:02: at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0