Tk-multi-publish2 - How to set summary_thumbnail?


I am looking for a way to set the summary_thumbnail.

In my collector plugin, I am setting the parent_item’s thumbnail with the following code:

thumb_path = tempfile.NamedTemporaryFile(suffix='.jpg', prefix='sgtk_thumb', delete=False).name
thumbnail_path = publisher.engine.generate_thumbnail(document, thumb_path)

That works great, but the summary item remains empty, only the items below it get the thumbnail update. How can I set the summary_thumbnail…?



Hey @richbobo,

Not quite sure myself, grabbing a colleague to check this out.


Hi @richbobo

Just to confirm this is the bit you would like to set the icon on?

If so I don’t think there is a way, as it’s not actually a publish item, but is used to set details across items.

Presumably your able set the same icon across all items, it’s just that you would like it to visually display in the summary?


Yes, that’s exactly it.

I got some help from a colleague last night, sine he has done a lot of work with Qt user interface stuff. I thought that maybe if I could get the Dialog, I could hijack its _update_item_thumbnail() method. We were able to get the panel but, for some reason, the updating is not working. Here’s our WIP, hacky code:

        ps_panel = engine._get_dialog_parent()

        top_level = QtGui.QApplication.topLevelWidgets()
        found_objects = []

        for widget in top_level:
            if hasattr(widget, "_update_item_thumbnail"):
                self.logger.debug('Found: ---> {}'.format(widget.objectName()))
            for child in widget.findChildren(QtCore.QObject):
                if hasattr(child, "_update_item_thumbnail"):
                    self.logger.debug('Found: ---> {}'.format(child.objectName()))

        pixmap = QtGui.QPixmap(thumbnail_path)
        self.logger.debug('pixmap: ---> {}'.format(pixmap))
        if len(found_objects):
            self.logger.debug('Num Objects: {}'.format(len(found_objects)))
            for found_object in found_objects:
                    EVENTS = ShowEvent(found_object, ps_panel)

class ShowEvent(QtCore.QObject):

    def __init__(self, found_object, parent=None):
        super(ShowEvent, self).__init__(parent=parent)
        self._found_object = found_object

    def eventFilter(self, obj, event):
        if event.type() == QtCore.QEvent.Show:
            thumbnail_path = r'C:/Users/rich.boboApp/Data/Local/Temp/sgtk_thumbizl4f_.jpg'
            pixmap = QtGui.QPixmap(thumbnail_path)

        return QObject.eventFilter(self, obj, event)

Hmm… that formatting got a little messed up, but hopefully you get the idea.

When I run that, I get:

Collecting items to Publish...
  DEBUG: thumbnail_path: ---> c:\users\rich~1.bob\appdata\local\temp\sgtk_thumbqqbwua.jpg
  DEBUG: Found: ---> Dialog
  DEBUG: pixmap: ---> <PySide.QtGui.QPixmap object at 0x000000001155F548>
  DEBUG: Num Objects: 1
  Work template '<Sgtk TemplatePath 2d_asset_work_photoshop: _assets/{sg_asset_type}/{Asset}/2d/_workarea/{Step}/{Asset}[_{content}]_{Step}_{version}.[{iteration}.]{ps_extension}>' defined for Photoshop.
  Collected Photoshop document: my_test_asset_txt_026.006.psd
  Collected Photoshop layer: 91332602_FOP_ART
  Collected Photoshop layer: 91332602_FOP_DIE
  Collected Photoshop layer: 91332602_FOP_ALPHA
  Photoshop 'Publish to Shotgun' plugin accepted document: my_test_asset_txt_026.006.psd.
6 items discovered by publisher.
1 Like

So, as I mentioned, I am able to get the Dialog, and I don’t get any errors when I try to update the summary thumbnail. What we were wondering is if maybe we’re setting it too early and the summary details are built afterward, stepping on the thumbnail. We left off last night, trying to get a record of the events, to see if we could tell what’s happening (or not happening). But, that’s as far as we got before we ran out of gas… ;^)

1 Like

Yeah I would have thought _update_item_thumbnail would have done the job, but I’m not sure why thats not working for you without digging in deeper, and unfortunately I don’t have the time at the moment.


1 Like

OK, thanks for checking. I did just verify that the function is not being fired. I put a “GOT HERE” log statement in there and I only see it if I manually do the screengrab.

I’ll poke around some more and see if I can make it work. The thumbnail module’s _set_screenshot_pixmap() function is run when the manual grab is done, so I’m going to see if I can attack it from that direction…



After many hours, I finally stumbled on a solution!

I am getting the Dialog UI Class and using its methods to set the summary_thumbnail and thumbnails of all the items in the tree.

This code is in my collector plugin:

    thumbnail_path = parent_item.get_property('thumbnail_path')

    pixmap = QtGui.QPixmap(thumbnail_path)

    top_level_widgets = QtGui.QApplication.topLevelWidgets()

    for widget in top_level_widgets:
        child = None
        if hasattr(widget, "_summary_thumbnail"):
            Dialog = widget
        for child in widget.findChildren(QtCore.QObject):
            if hasattr(child, "_summary_thumbnail"):
                Dialog = child

    # Edited code snippet, borrowed from dialog._update_item_thumbnail().
    if not Dialog._current_item:
        # This is the summary item.
        Dialog._summary_thumbnail = pixmap
        if pixmap:
            # Update all items with the summary_thumbnail.
            for top_level_item in \
                top_level_item.thumbnail = Dialog._summary_thumbnail
                top_level_item.thumbnail_explicit = False
1 Like