Publisher2 - Custom UI - Initialize values, even when not selected in UI

Hello group,

So I’ve added some widgets in the Publisher (Houdini) to submit stuff to the farm.
I’m fetching data (pools, groups, etc) out of Deadline and populate some comboboxes in the Publisher to give the artists some more freedom in the Publishing/Submission process.

So all the widgets populate nicely and everything works as expected.
But only when the user clicked the publish item on the left do display it’s custom widgets.

If I have for instance 4 items on the left and I hit Publish without having displayed it’s widgets, the publish fails and after some digging it appears the values out of the comboboxes are not there when we haven’t displayed them in the UI.

As soon as I clicked all the items on the left to display their custom widgets, the publish works.
Is there are way to force the values to be present even if we having changed them?

So my code looks something like this (pretty simple):

settings:

        "render_pool": {
            "type": "dict",
            "default": None,
            "description": "Sets the Deadline Render pool."
def create_settings_widget(self, parent):
    self.cbx_widget = DeadlineArgs(parent, self.parent.shotgun)
    return self.cbx_widget

def get_ui_settings(self, widget):
    return {"render_pool": widget.pool_selection}

def set_ui_settings(self, widget, settings):
    pool = setting_block.get("render_pool")
    if pool:
        widget.pool_selection = pool

def __init__(self, parent, sg):

    super(DeadlineArgs, self).__init__(parent)
    self.__populate_pools(sg, self.pool_cmbx)
    self.__setup_ui()

    @property
    def pool_selection(self):
        index = self.pool_cmbx.currentIndex()
        return self.pool_cmbx.itemData(index)

    @pool_selection.setter
    def pool_selection(self, value):
        index = self.pool_cmbx.findData(value)
        self.pool_cmbx.setCurrentIndex(index)

def __populate_pools(self, sg, combobox):

    #First we manually add our prefered group, so it's selected by default
    combobox.addItem("gpu-farm", "gpu-farm")

    # Now add all the found pools to the pool combo box.
    for pool in pools:
        if not "gpu-farm" in pool:
            combobox.addItem(pool, pool)

you should try

combobox.setCurrentIndex(0)

or

combobox.setCurrentText("gpu-farm")

https://doc.qt.io/qt-5/qcombobox.html

Yeah, I am using the self.pool_cmbx.setCurrentIndex(index) already…
That’s why I’m asking :wink:

You are using it in the setter, but that only gets set conditionally

if pool:
...

Did you try to set the default in settings to gpu-farm? This would probably work.
In set_ui_settings, you probably haven’t set an item yet in the settings.
(the code formatting makes it a bit difficult to read. Use triple backticks to start and end the block)

Aah yeah, thanks for the heads up about the code blocks.

In the settings I set it to None and populate the first entry in the combobox in the populate function.

I tried setting it in settings, but couldn’t get it to work.
If I try something like {‘pool’: ‘gpu-farm’}, it doesn’t work.
Or just “gpu-farm” also doesn’t work.

                "type": "dict",
                "default": None,
                "description": "Sets the Deadline Render pool.

On indeed it’s a dict. I thought Deadline pools are passed as just names?
What does the pool dict look like?

Basically, you are not setting the actual setting, just the combobox item.

Yeah, they are passed as strings. But I’m handling that later in the process.
I’m just wondering what the syntax for dicts in the settings should be.
I recon just something like {“pool”: “gpu-farm”}

So I’m just adding the items to the combobox like this:

def __populate_pools(self, sg, combobox):

        #First we manually add our prefered group, so it's selected by default
        combobox.addItem("gpu-farm")

        # Now add all the found pools to the pool combo box.
        for pool in pools:
            if not "gpu-farm" in pool:
                combobox.addItem(pool)

You might be confused about it. Your pool setting can be a string. The settings themselves are a dict. This defines the render_pool setting:

@property
def settings(self):
  return {
    "render_pool": {
      "type": "string",
      "default": "gpu-farm"
      "description": "..."
    }
  }

if I’m understanding correctly, this should solve your problem.

1 Like

Well you know this solved it!
I also had the type on “str” the whole time. Not sure if this is supported or not.
But now it works.

Thanks a lot for your help!

Glad to hear