Publish2 custom plugin UI example

I thought I would share an example of a Publish custom plugin UI.

The example extends the standalone hook, to add options for setting the task’s status to “pending review”, and adding a reviewer.

It dynamically lists people as reviewers who are on the same project and are in a “Review” group.

For example “Jim the bad reviewer” is not appearing in the list as no one will let him work on any projects!

To use the plugin download this script, and place it in your config’s hooks/tk-multipublish2/ directory (you may need to create the `tk-multi-publish2 folder inside hooks.)

Then open env/includes/settings/tk-multi-publish2.yml and modify the standalone publish settings to add :{config}/tk-multi-publish2/" to the Publish to Shotgun hook:
  collector: "{self}/"
    - name: Publish to Shotgun
      hook: "{self}/{config}/tk-multi-publish2/"
      settings: {}
    - name: Upload for review
      hook: "{self}/"
      settings: {}
  help_url: *help_url
  location: ""

You must make sure to select a Task for your publish item, otherwise it will not be able to set the status or reviewer.
Note this is NOT intended to be a production ready plugin, it is merely here as an example.

The three key methods used to generate a custom UI are:

It is also important to define any custom settings you may want to store from your UI in the settings() method.


Is it possible to use these methods to add custom widgets to this section of the main item?


Unfortunately at present you can’t add a custom UI to the item, only to the plugins. We have heard this request before though, I’ll an idea suggestion to our roadmap on your behalf.


Thanks Phil - this would be very useful!

We don’t want to have to fork and adjust the UI files to get our custom fields in - would be great if we could update via a hook.


How do you redraw the main session UI if you click back to it?
Once the new UI is active it stays put no matter which publisher item you click on.

It seems like re-implementing the get_ui_settings method is breaking functionality. Even though I return a dictionary of my updated settings, it seems to cause the UI to get stuck on that widget. (where those settings are getting saved, I think) are not triggering the save for the settings. seems like a module that I probably shouldn’t be modifying but for instance

def _pull_settings_from_ui(self, selected_tasks):
    Retrieves settings from the UI and updates the task's settings.

    :param selected_tasks: A :class:`TaskSelection` of tasks to update based
        on the values edited in the UI.
    if selected_tasks.has_custom_ui:
        widget = self.ui.task_settings.widget
        settings = self._current_tasks.get_settings(widget)
        # TODO: Implement getting the settings from the generic UI, if we ever implement one.
        settings = {}

    # Update the values in all the tasks.
    for task in selected_tasks:
        # The settings returned by the UI are actual value, not Settings objects, so apply each
        # value returned on the appropriate settings object.
        for k, v in settings.iteritems():
            task.settings[k].value = v

in, self._current_tasks (which is needed to trigger the save) does not seem to contain any pertinent information. At least none that I can see in the logger.

Surely I can’t be the only one whose played around with this and has run into this issue.

Hi @StarkRavenSimone, I’m sorry you’re encountering issues. I’ve not seen this behavior before or heard of it being reported.
Unfortunately, I don’t have the time right now to dig in and test this, but I will hopefully do on Friday if someone else doesn’t get to this before then.

I figured it out.

I forgot to include the new settings values being stored in the settings function.
Works great now.



Hey philip,
I’ll just have to ask to be sure:

Unfortunately at present you can’t add a custom UI to the item, only to the plugins.

Is it correct, that in your example every file you want to publish gets the same reviewer?
I am trying to let the user choose the published file type for each file by hand, but the selected file type is then the same for every published file and when i click away from the UI, the selected Publish File Type jumps to default again.
Am I doing something wrong or ist this just not doable at the moment?

1 Like

Hi @jonase
I believe this is the case right now, but I’ll check with someone else and get back to you.
You don’t know the item unfortunately when creating the UI, so I don’t think there is a way to make the setting specific to the item.

Thanks Philip!
If thats the case I would really appreciate if someone knows a smart way to be more specific
with the Publish File Type, because right now it only looks at the extension of the file.
So every .exr becomes an Image File, but in our case actually could be a Rendered Image OR a Plate.

Kind regards

1 Like

I’m not sure what logic you would apply to work out whether is a Plate or a Rendered Image but to programmatically set it, you could either set the item’s publish_type property at collection time:["publish_type"] = "Plate" if ... else "Rendered Image"

or you could override this method:

And implement your own logic there.

1 Like