Skip to content

Instantly share code, notes, and snippets.

@nicelifeBS
Created February 24, 2017 09:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicelifeBS/de28a348aed022766ffaffa2913c5b2c to your computer and use it in GitHub Desktop.
Save nicelifeBS/de28a348aed022766ffaffa2913c5b2c to your computer and use it in GitHub Desktop.
KATANA: How to layout widget like Katana does it
import UI4.FormMaster.PythonValuePolicy
# Create a node for which to create parameter widgets
node = NodegraphAPI.CreateNode('Alembic_In', NodegraphAPI.GetRootNode())
# Get a couple of parameters from the node
addForceExpandParameter = node.getParameter('addForceExpand')
addBoundsParameter = node.getParameter('addBounds')
fpsParameter = node.getParameter('fps')
# Create parameter policies for the parameters
addForceExpandParameterPolicy = UI4.FormMaster.CreateParameterPolicy(None, addForceExpandParameter)
addBoundsParameterPolicy = UI4.FormMaster.CreateParameterPolicy(None, addBoundsParameter)
fpsParameterPolicy = UI4.FormMaster.CreateParameterPolicy(None, fpsParameter)
# Create a policy to group the above parameter policies, and set a widget hint on it to hide the group's title
myGroupPolicy = UI4.FormMaster.PythonValuePolicy.PythonValuePolicy('myGroup', {})
myGroupPolicy.addChildPolicy(addForceExpandParameterPolicy)
myGroupPolicy.addChildPolicy(addBoundsParameterPolicy)
myGroupPolicy.addChildPolicy(fpsParameterPolicy)
myGroupPolicy.getWidgetHints()['hideTitle'] = True
# Create and show the parameter widgets
groupFormWidget = UI4.FormMaster.KatanaFactory.ParameterWidgetFactory.buildWidget(None, myGroupPolicy)
groupFormWidget.show()
@nicelifeBS
Copy link
Author

Sorting the widgets order:

...
myGroupPolicyData = {
    '__childOrder': ['fps', 'addForceExpand', 'addBounds'],
}
myGroupPolicy = UI4.FormMaster.PythonValuePolicy.PythonValuePolicy('myGroup', myGroupPolicyData)
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment