Skip to content

Added ButtonDef Attribute Definition.#1739

Closed
matthewstantonBK wants to merge 3 commits intoynput:developfrom
matthewstantonBK:feature/YN-0534_Publisher_Add_ButtonDef_implementation
Closed

Added ButtonDef Attribute Definition.#1739
matthewstantonBK wants to merge 3 commits intoynput:developfrom
matthewstantonBK:feature/YN-0534_Publisher_Add_ButtonDef_implementation

Conversation

@matthewstantonBK
Copy link
Copy Markdown

Changelog Description

This PR introduces a new attribute definition for publish plugins called ButtonDef,
As the name implies this allows the addition of buttons to pre-create, create and publish attributes.
This new attribute works using a callback value passed into the ButtonDef when initialised.
This callback method will take in an instance_data dictionary and output a dictionary, what both these dictionaries are vary based on if the attribute definition is for pre-create, create or publish.
For both create and publish attribute definitions this will be an input of the instance.data and the output is used to update the instance.data. This will allow buttons to be used for setting of instance.data as well as setting of both publish and creator attribute values.
For pre-create attributes, since no instance exists yet, the instance_data passed in is just a dictionary of key, pre-create attribute definition name, to value, value that the widget connected to that attribute definition holds. The dictionary returned should follow the same format but instead be used to update these values for the current creator. This allows pre-create buttons to simply update other attribute definitions.

Additional info

This was required as the 2D team requested a framerange selection tool that was done through the Nuke pop-up window that appears within Nuke when running a write. To do this I decided to create the ButtonDef to launch the pop-up and allow them to select a framerange and it then update the instance data to match that.
It has now been requested in a ticket so I am creating this MR.

Example

I have created two files to show you how this Attribute Def Works, a creator and a plugin, both are attached.
collect_test_buttondef.py
create_test_buttondef.py
Both of these files were made for the Traypublisher.
The Examples just show how a button can be used with pre-create, create and publish attributes with each section containing the same attribute definitions.
The first part of this is a button that opens a QDialog that has a checkbox, when the dialog is accepted a TextAttr's value is set to True or False based on the checkbox value.
The second part is a button which will take the text from one TextAttr and copy it to another one.
Both the publish and create attributes add a key, value directly into the instance data to also show how the buttons can directly affect the instance.data.
In this example the plugin not only holds the publish attribute definitions but also when run will log out all data to do with the instance and raise an error to stop the publish as the instance created by the creator is not actually meant to be published. The pre-create data is also added to the instance.data on instance creation so the plugin can log the data from that as well.
This plugin will allow you to see the instance.data has successfully been updated through the buttons.

Testing notes:

Realistically testing is quite open with this since this is an attribute definition and can be used in a variety of ways.
The provided example is a good way to test all the updates are working.
If you want to manually test this:

  1. You will have to create a function that adjusts the data in some way. For pre-create, as explained above, this will take a dictionary linking attribute definition key to attribute definition widget value and output a dictionary in the same format but to update the widget values. With create and publish attributes it's the same idea but with instance.data. See the example to properly understand how to write one of these functions.
  2. Either add a ButtonDef Attribute to an existing creator or create a new creator specifically to test this. To test create add a ButtonDef to the return list of the method get_instance_attr_defs for pre-create add it to the return list of get_pre_create_attr_defs. For publish attributes the ButtonDef will need to be added to the return value of get_attr_defs_for_instance in a publish plugin. A ButtonDef is initialised using:
ButtonDef(attribute_def_key, text=text_to_show_on_button, callback=the_data_update_method)
  1. The final step is just running the publish and checking the data was correctly updated based on what you wrote your callback method to do. This can be through changing other attribute values and seeing if they are updated in the UI, changing something like framerange and seeing if that is correct in the final publish or just logging out the data like in my example.

@ynbot ynbot added size/S type: feature Adding something new and exciting to the product labels Mar 6, 2026
@matthewstantonBK matthewstantonBK marked this pull request as ready for review March 6, 2026 14:59
@BigRoy BigRoy requested review from BigRoy and iLLiCiTiT March 6, 2026 15:05
@iLLiCiTiT
Copy link
Copy Markdown
Member

Closed in favor of #1770

@iLLiCiTiT iLLiCiTiT closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S type: feature Adding something new and exciting to the product

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants