Custom input dialog (GUI only)
In scripts it is especially preferable to show a single dialog when multiple inputs are needed. For this you can use lux.getInputDialog(). The scripts provided by Luxion will use this.
As an example, if we wanted to write a video encoding script the following dialog might suffice:
>>> values = [("folder", lux.DIALOG_FOLDER, "Folder with frames:", None), \
("fmt", lux.DIALOG_TEXT, "Frame file format:", "frame.%d.jpg"), \
("start", lux.DIALOG_INTEGER, "Start frame:", 1, (1, 4096)), \
("end", lux.DIALOG_INTEGER, "End frame:", 10, (1, 4096)), \
("fps", lux.DIALOG_INTEGER, "FPS:", 10, (1, 1024)), \
("name", lux.DIALOG_TEXT, "Video name:", "video.mp4")]
>>> opts = lux.getInputDialog(title = "Encode Video", \ # Shows the dialog.
desc = "Put a description here.", \
values = values)
>>> opts
{'end': 10, 'fps': 10, 'fmt': 'frame.%d.jpg', 'name': 'video.mp4', 'start': 1, 'folder': ''}
If you click “OK” without changing any values then you will get the Python dictionary above. Each key is associated with the value from the dialog.
Note
The “\” characters above indicates a continuation of the line, so it is not split into several lines, but understood as one line.
For scripts that are run often it is convenient to have KeyShot remember the last values for when the dialog is displayed again, and that is accomplished by using a unique value for the id option:
>>> opts = lux.getInputDialog(title = "Encode Video", \
desc = "Put a description here.", \
values = values, \
id = "something_unique_goes_here")
If the unique value is already used by some other script then you will get undesired results. However, keep in mind that your script must use the same unique value each time to retrieve your values.