Follow this blog

Customize in /user/extras/follow-sheet.tmpl.php.

Sample text.

Telegram, X or  Twitter, Facebook, VK, LinkedIn, Odnoklassniki, Pinterest, YouTube, TikTok, RSS JSON Feed

Sample text.

Boring Image Processing Blog

GitHub   About

Adding a Slider to an Integer Knob

By default, an integer knob in Nuke is created without a slider. While this works fine, adding a slider definitely provides a better UX.

You can force a slider to appear using setFlag(). The problem, however, is that as soon as the node is re-initialized — like during a copy/paste or when reloading the script — the flag resets, and the slider vanishes.

The solution is to inject the flag configuration into the onCreate callback. It’s a bit of a hack, sure, but it gets the job done. Here is an example for an integer knob named smooth_strength:

set_slider = "nuke.thisNode()['smooth_strength'].setFlag(0x0000000000000002)"
nuke.selectedNode()['onCreate'].setValue(set_slider)

If needed, you can also define the range and default value right then and there:

set_slider = """
node = nuke.thisNode()
node['smooth_strength'].setFlag(0x0000000000000002)
node['smooth_strength'].setRange(1,50)
node['smooth_strength'].setDefaultValue([10])
"""
nuke.selectedNode()['onCreate'].setValue(set_slider.strip())

This will add a new line inside the node’s data. To see the result, you’ll need to re-initialize the node so the onCreate callback triggers — simply cutting and pasting the node will do the trick.

Shoutout to Attila Gasparetz, where I originally borrowed this clever solution from.