AWS Thinkbox Discussion Forums

How to put an image control in a script dialog?

I’m venturing into making a script for the Deadline Monitor and I want to display an image in a box. Python is not my forté currently. I’ve done some digging and found this example of how to use pyQT with Deadline, which works.

Has anyone got a snippet to put an image control in? Doesn’t appear to be that simple and I can find dozens of different examples in Python for making image controls, but so far I’ve got none of them to work.

[code]from PyQt4.QtCore import *
from PyQt4.QtGui import *

########################################################################

Globals

########################################################################
dialog = None

########################################################################

Custom QDialog with some basic controls.

########################################################################
class CustomQtDialog(QDialog):

def init(self, parent=None):
super( CustomQtDialog, self ).init( parent )

  #set the main layout as a vertical one
  self.mainLayout = QVBoxLayout()
  self.setLayout( self.mainLayout )

  #a label to display stuff
  self.displayLabel = QLabel( "Click a button!" )
  self.mainLayout.addWidget( self.displayLabel )

  #this horizontal layout will contain a bunch of buttons
  

  self.buttonLayout = QHBoxLayout()
  self.button1 = QPushButton( "1" )
  self.buttonLayout.addWidget( self.button1 )

  self.button2 = QPushButton( "2" )
  self.buttonLayout.addWidget( self.button2 )

  self.closeButton = QPushButton( "Close" )
  self.buttonLayout.addWidget( self.closeButton )

  self.mainLayout.addLayout( self.buttonLayout )

  #hook up the button signals to our slots
  self.button1.clicked.connect( self.button1Pressed )
  self.button2.clicked.connect( self.button2Pressed )
  self.closeButton.clicked.connect( self.closeButtonPressed )

@pyqtSlot( bool )
def button1Pressed( self, checked ):
self.displayLabel.setText( “You pressed the first button!” )

@pyqtSot( bool )
def buttlon2Pressed( self, checked ):
self.displayLabel.setText( “You pressed the second button!” )

@pyqtSlot( bool )
def closeButtonPressed( self, checked ):
self.done( 0 )

########################################################################

Main Function Called By Deadline

########################################################################
def main():
global dialog

#Create an instance of our custom dialog, and show it
dialog = CustomQtDialog()
dialog.setVisible( True )[/code]

Here you go Dave.

[code]import sys

from Deadline.Scripting import *

from PyQt4.QtCore import *
from PyQt4.QtGui import *

########################################################################

Globals

########################################################################
dialog = None

########################################################################

Custom QDialog with some basic controls.

########################################################################
class CustomQtDialog(QDialog):

def __init__(self, parent=None):
    super( CustomQtDialog, self ).__init__( parent )

    #set the main layout as a vertical one
    self.mainLayout = QVBoxLayout()
    self.setLayout( self.mainLayout )

    randomImage = "Z:\\Thinkbox\\DeadlineRepository62\\submission\\MayaVRayDBR\\Main\\SubmitVRay.png"

    #display an image
    self.pixMap = QPixmap( randomImage )
    self.imageLabel = QLabel( )
    self.imageLabel.setPixmap(self.pixMap)
    self.mainLayout.addWidget( self.imageLabel )

    #a label to display stuff
    self.displayLabel = QLabel( "Click a button!" )
    self.mainLayout.addWidget( self.displayLabel )

    #this horizontal layout will contain a bunch of buttons
    self.buttonLayout = QHBoxLayout()
    self.button1 = QPushButton( "1" )
    self.buttonLayout.addWidget( self.button1 )

    self.button2 = QPushButton( "2" )
    self.buttonLayout.addWidget( self.button2 )

    self.closeButton = QPushButton( "Close" )
    self.buttonLayout.addWidget( self.closeButton )

    self.mainLayout.addLayout( self.buttonLayout )

    #hook up the button signals to our slots
    self.button1.clicked.connect( self.button1Pressed )
    self.button2.clicked.connect( self.button2Pressed )
    self.closeButton.clicked.connect( self.closeButtonPressed )

@pyqtSlot( bool )
def button1Pressed( self, checked ):
    self.displayLabel.setText( "You pressed the first button!" )

@pyqtSlot( bool )
def button2Pressed( self, checked ):
    self.displayLabel.setText( "You pressed the second button!" )

@pyqtSlot( bool )
def closeButtonPressed( self, checked ):
    self.done( 0 )

########################################################################

Main Function Called By Deadline

########################################################################
def main():
global dialog

#Create an instance of our custom dialog, and show it
dialog = CustomQtDialog()
dialog.setVisible( True )[/code]
Privacy | Site terms | Cookie preferences