Working with modules from Lua scripts in darktable

You can manipulate sliders and comboboxes (and some other widgets and commands) from lua in the same way as you can via the shortcut system, using the darktable.gui.action command.

In 4.2 the exact command will be shown in the tooltip when in shortcut mapping mode.
image

Used like this, the command will trigger the default action, which is to show the popup. If you want to change the value you can specify the “set” effect (in the last but one parameter). Then the last parameter will be used to set the slider value. Or, if it is empty, the current slider value will be returned.

For convenience, you can create the shortcut, set all the values as you want them (and test if it works as expected) and then press ctrl+C (while the shortcut is selected) to copy the exact lua command needed to the clipboard.

This:

would give this:
dt.gui.action(“iop/exposure/exposure”, 0, “value”, “set”, 0.500000)

If you have multiple instances of a module, the second parameter (normally 0) can indicate which one to affect.

4 Likes