Shotgun Playback Label Widget¶
The Shotgun Playback Label is a simple
QLabel override which
makes it easy to indicate that a thumbnail can be played back:
The widget takes care of analyzing provided shotgun data, and in case the Shotgun data contains playable media, the playback icon will automatically appear. Clicking the playback icon will launch a playback action, currently launching Shotgun screening room in a web browser.
In order to use this widget in QT designer, you need to wrap the import in a module. For more information on how to do this, see Using widgets with QT Designer.
Use the label like this:
playback_label = sgtk.platform.import_framework("tk-framework-qtwidgets", "playback_label") # construct label object label = playback_label.ShotgunPlaybackLabel(parent_widget) # always use label with a pixmap label.setPixmap(some_pixmap_object) # pass a shotgun data dictionary to tell the label what data we are # operating on. Make sure to include relevant fields - for example, # if you are passing version data, make sure to include media fields label.set_shotgun_data(sg_data) # we can check if an icon is displayed print "Playback icon displayed: %s" % label.playbable # and we can hook it up to other things label.playback_clicked.connect(some_callback)
QLabelthat displays a playback icon centered above its content.
While it is technically possible to use this label with text based content, we strongly recommend using it with a pixmap. Typically this is a Shotgun thumbnail.
By populating an instance with shotgun version data via the
set_shotgun_data()method, the label will look at the data and determine whether a playback icon should be displayed or not. In the case an icon is displayed, a playback_clicked signal may be emitted.
Signal playback_clicked(dict): The playback icon was clicked. This signal passes the shotgun version data specified in via the
set_shotgun_data()method back to the caller.
Parameters: parent – QT parent object
Sets shotgun data associated with this label. This data will be used to drive the logic which is used to determine if the label should exhibit the playback icon or not.
If you for example are passing a Shotgun data dictionary reprensenting a version, make sure to include the various quicktime and frame fields.
Parameters: sg_data – Shotgun data dictionary
Returns True if the label is playable given its current Shotgun data.