AWS Thinkbox Discussion Forums

Dynamic GUI

I’m using Deadline 6.
Would it be possible to make GUI with buttons for adding and removing text fields? Pretty much I was hoping for something like scriptDialog.RemoveControl(), but since that’s not there, maybe there’s an alternative.

Hm, I guess I answered my own question. Just going to toggle visibility and keep the Add and Remove buttons static.

Hello,

Glad to hear you got it all sorted!

Hello,
I’m coming back to this after a while because things continue to come up that the DeadlineScriptDialog can’t seem to handle. Is it possible to use PyQt with these dialogs in order to create more dynamic user interfaces? I can’t find any documentation for it.

You should be able to use PyQt stuff for the interface… Our ScriptDialog is just a subclass of QDialog with some sugar on top to match our older API, so anything you can do with a QDialog you should be able to do with our ScriptDialog (including adding other Qt controls and layouts to it manually). You could also just not use our ScriptDialog at all, and just create your own QDialog, of course.

We don’t have documentation for the PyQt stuff explicitly, since all that stuff is pretty well documented elsewhere. I suppose we could definitely do a better job of surfacing the fact that this is indeed something that can be done, though.

I’ll see if I can’t whip up a quick example script to get you on the right track.

Cheers,

  • Jon

I’ve attached a really simple Qt GUI with a few buttons and an updating label. Note that I don’t really have any Deadline-specific code in there (aside from creating the dialog in the main function), but all the calls to the Deadline API should remain the same as if you were using a ScriptDialog.

Let me know if you have any questions!

Cheers,

  • Jon

[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!" )

@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]
QtUIExample.zip (786 Bytes)

Thanks Jon,
This is very helpful. It took me a while to realize that to do something like adding a QTreeWidget to a DeadlineScriptDialog, I could do something like this:

tabWidget = scriptDialog.AddTabPage("Tab Page")

treeRow = scriptDialog.AddRow()
scriptDialog.AddControl( "SomeLabel", "LabelControl", "Some Label", labelWidth, -1, "A label." )
scriptDialog.EndRow()

treeWidget = QTreeWidget(tabWidget)
treeWidget.setObjectName("TreeWidget")
treeWidget.setFixedWidth(dialogWidth - labelWidth - 24)
treeWidget.setFixedHeight(150)

treeRow.insertWidget(1, treeWidget)

scriptDialog.EndTabPage()

It’s good that it’s possible to mix the two together.

I had a further question about this which I think might be more appropriate for these forums rather than the Qt forums. How would I access Deadline Qt icons? I’m trying to keep the dialog style still looking like Deadline. I’m customizing a QTreeView according to http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtreeview. However, I don’t know where to access Deadline icons for vline.png, branch-more.png, branch-end.png, branch-closed.png, or branch-open.png.

We’re not using custom icons for the border-image in any of our tree views at all, so I’m not sure which icons you’d be looking for… Unless you’re just asking how to add your own custom icons? In which case, I’m not sure – all of our icons get compiled into a resource file at build-time, I’ve never tried loading an arbitrary icon external to that. I’m sure there’d be a way to load in stuff directly from the disk though, as long as Qt can find it.

I put together some images to make it clearer. tree-default.jpg is what you get by default on Windows 7 when you create a QTreeWidget without any style sheet applied. tree-deadline.jpg is what I get when I create a QTreeWidget with Deadline. The difference I’m talking about is that the default uses little arrow icons for the expand / close children buttons, but for Deadline they’re little + / - icons. So what I’m going for is exactly in tree-deadline-expand-only.jpg. This picture isn’t real, I Photoshopped tree-deadline.jpg into tree-deadline-expand-only.jpg to make it look like what I want. I thought that Deadline was using custom icons for the QTreeWidget lines since it looks different than what the default looks like such as arrows vs. + / -, and dashed lines instead of no lines. Sorry if this is more of a Qt question, I’m just not sure where to draw the line between Qt and Deadline for this particular question.
tree-deadline-expand-only.jpg
tree-deadline.jpg
tree-default.jpg

Ah, gotcha. Yeah, it’s different in Deadline than default Qt because we’re using the Plastique Qt style, instead of whatever it defaults to (and a palette for the colours, but the icons are coming from the Qt style).

So anyways, you’re basically looking for only the top-level items to be expandable (and the children are always expanded)?

It sounds like it should be doable with a QTreeWidget (with code similar to below), but I couldn’t get it to work in practice:

treeWidget = QTreeWidget()
self.mainLayout.addWidget(treeWidget)
item = QTreeWidgetItem( treeWidget )
item.setText( 0, "test" )

item2 = QTreeWidgetItem( item )
item2.setText( 0, "testChild")

item3 = QTreeWidgetItem( item2 )
item3.setText( 0, "A")

item4 = QTreeWidgetItem( item2 )
item4.setText( 0, "B")

item2.setChildIndicatorPolicy( QTreeWidgetItem.DontShowIndicator )
item2.setExpanded( True )

Unfortunately, this code doesn’t work for me though – the +/- indicator does get hidden, but it’s not getting expanded by the setExpanded call (which works fine if the indicator isn’t hidden)… The setChildIndicatorPolicy function definitely seems like the ticket, but it seems that it’s also preventing it from being opened at all, even programmatically. I guess this is where this question becomes more suited for the Qt guys :slight_smile:

Thanks for the explanation. You’ve been very helpful.

Privacy | Site terms | Cookie preferences