# Tk-multi-publish2 custom widget settings based on publish item

**URL:** <https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690>\
**Category:** Pipeline Integrations\
**Tags:** bug-fixed\
**Created:** [August 21, 2019, 1:59pm UTC](https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690 "2019-08-21T13:59:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonas.lindfors](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/jonas.lindfors/32/1046_2.png) [@jonas.lindfors](https://community.shotgridsoftware.com/u/jonas.lindfors)\
**Post date:** [August 21, 2019, 1:59pm UTC](https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690/1 "2019-08-21T13:59:10Z")

</div>

Hello Shotgunners!

I have added a custom widget (combobox) to a publish plugin in the publisher, and would like to set my combobox to a value based on the item. Is it possible to talk to my widget from the accept method or so?

Basically I want to look at the items path and change the combobox current item based on what I can find in the path.

Cheers,  
Jonas

---

<div class="post-metadata">

**Author:** ![tannaz](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/tannaz/32/32_2.png) [@tannaz](https://community.shotgridsoftware.com/u/tannaz)\
**Post date:** [August 22, 2019, 2:10am UTC](https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690/2 "2019-08-22T02:10:26Z")

</div>

Hi Jonas! I’m gonna run this by an engineer, but off the top of my head, I think the answer, sadly, is no.

It looks like the [`create_settings_widget()` method](https://developer.shotgunsoftware.com/tk-multi-publish2/customizing.html#tk_multi_publish2.base_hooks.PublishPlugin.create_settings_widget), which is what you use to add custom UI, doesn’t take anything but the parent widget, so I don’t see how you could pass it the return value from `accept()`. It’s a good request though – I’ll see if I can get more info for you.

---

<div class="post-metadata">

**Author:** ![tannaz](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/tannaz/32/32_2.png) [@tannaz](https://community.shotgridsoftware.com/u/tannaz)\
**Post date:** [September 7, 2019, 12:01am UTC](https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690/5 "2019-09-07T00:01:44Z")

</div>

Hi Jonas –

Just wanted to follow up on this one. I had a hunch that you might be able to do this by populating `self.items` and then referring to that attribute inside `set_ui_widgets()` , but I ran it by an engineer, and it sounds like that won’t work:

> Unfortunately you don’t have access to the item object during create\_settings\_widget, get\_ui\_settings and set\_ui\_settings, so it’s not possible to know how the settings you are displaying relate to other settings on other items in the scene and what items are child of the currently selected one.

In order to do this, we need to augment these UI methods to also pass in the PublishItem. I’ve shared that request with the product team.

---

<div class="post-metadata">

**Author:** ![jonas.lindfors](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/jonas.lindfors/32/1046_2.png) [@jonas.lindfors](https://community.shotgridsoftware.com/u/jonas.lindfors)\
**Post date:** [September 7, 2019, 10:38am UTC](https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690/6 "2019-09-07T10:38:42Z")

</div>

Hi Tannaz,

Thanks for looking in to this. It’s not something I can’t live without, more of a nice-to-have feature.

Cheers,  
Jonas

---

<div class="post-metadata">

**Author:** ![nico.vandenbosch](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/nico.vandenbosch/32/4949_2.png) [@nico.vandenbosch](https://community.shotgridsoftware.com/u/nico.vandenbosch)\
**Post date:** [May 23, 2020, 12:05am UTC](https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690/8 "2020-05-23T00:05:24Z")

</div>

+1 on this feature request.

---

<div class="post-metadata">

**Author:** ![tannaz](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/tannaz/32/32_2.png) [@tannaz](https://community.shotgridsoftware.com/u/tannaz)\
**Post date:** [May 23, 2020, 1:20am UTC](https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690/9 "2020-05-23T01:20:48Z")

</div>

Roger that, Nico – I’ve made a note in the feature request.

---

<div class="post-metadata">

**Author:** ![Jonas](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/jonas/32/727_2.png) [@Jonas](https://community.shotgridsoftware.com/u/Jonas)\
**Post date:** [June 26, 2020, 3:21pm UTC](https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690/10 "2020-06-26T15:21:56Z")

</div>

Hello jonas,

I need the publish item most of the time when the `set_ui_settings` is called. E.g. to discover the manually set item context in the standalone publisher. So also from me a +1 🙂  
I’ve built a dirty workaround for that. Maybe the helps.

```auto
class BasicFilePublishPlugin(HookBaseClass):
    ....
    ....

    def set_ui_settings(self, widget, settings):
       
        publish_task = find_task_in_widget(widget)
        publish_item = publish_task.item #<--------------

def find_task_in_widget(widget):
    ui_holder_widget = widget
    infinity_loop_protector = -40
    while ui_holder_widget and not hasattr(ui_holder_widget, 'ui'):
        if not infinity_loop_protector:
            return None
        ui_holder_widget = ui_holder_widget.parent()
        infinity_loop_protector = infinity_loop_protector + 1

    if not ui_holder_widget:
        return None

    tree_items = ui_holder_widget.ui.items_tree.selectedItems()
    if not tree_items:
        return None
    return tree_items[0].task

```

Regards  
Jonas

---

<div class="post-metadata">

**Author:** ![tannaz](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/tannaz/32/32_2.png) [@tannaz](https://community.shotgridsoftware.com/u/tannaz)\
**Post date:** [August 12, 2020, 12:25am UTC](https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690/13 "2020-08-12T00:25:51Z")

</div>

Hi Jonases, Nico –

@Jonas, thanks for sharing your workaround and belated welcome to the forums!

I wanted to let you all know that we’ve addressed this feature request: we added an `items` parameter to the custom UI methods, so now you can access things like `item.context` in those methods. The fix is in `v2.5.4` of `tk-multi-publish2`, and you can [see more details in the release notes](https://github.com/shotgunsoftware/tk-multi-publish2/wiki/Release-Notes#v254).

Let us know if you have any other questions!

---

<div class="post-metadata">

**Author:** ![jonas.lindfors](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/jonas.lindfors/32/1046_2.png) [@jonas.lindfors](https://community.shotgridsoftware.com/u/jonas.lindfors)\
**Post date:** [August 12, 2020, 7:26am UTC](https://community.shotgridsoftware.com/t/tk-multi-publish2-custom-widget-settings-based-on-publish-item/690/14 "2020-08-12T07:26:05Z")

</div>

Great news, thanks!

/Jonas
