Added ButtonDef Attribute Definition.#1739
Closed
matthewstantonBK wants to merge 3 commits intoynput:developfrom
Closed
Added ButtonDef Attribute Definition.#1739matthewstantonBK wants to merge 3 commits intoynput:developfrom
matthewstantonBK wants to merge 3 commits intoynput:developfrom
Conversation
Member
|
Closed in favor of #1770 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
get_instance_attr_defsfor pre-create add it to the return list ofget_pre_create_attr_defs. For publish attributes the ButtonDef will need to be added to the return value ofget_attr_defs_for_instancein a publish plugin. A ButtonDef is initialised using: