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

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

2 Likes

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, 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.

3 Likes

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.

5 Likes

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

4 Likes

+1 on this feature request.

2 Likes

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

2 Likes

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 :slight_smile:
I’ve built a dirty workaround for that. Maybe the helps.

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

4 Likes

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.

Let us know if you have any other questions!

4 Likes

Great news, thanks!

/Jonas

3 Likes