I found by chance it was possible to display a combo box with zenity (version tested: 2.32.1). See the following code:
#!/bin/bash
array=(a b c d e)
value=$(zenity --entry --title "Window title" --text "${array[@]}" --text "Insert your choice.")
The result is illustrated with the following 3 images:
I have two questions about that:
Is there a documentation about this functionality? I didn't find anything in the zenity documentation.
Why the first value of my array doesn't appear in the combo box? In the example above, my array is
(a b c d e)
, and the combo box only displaysb c d e
.As a workaround, I add a value in my array, for example
(0 a b c d e)
.
This is actually documented (maybe not at the time the question was posted, didn't check), not in the manual but in
zenity --help-forms
:Therefore:
The first element of the array gets eaten up by
--text
. After expansion, your zenitiy line looks like:So you first set the text to
a
, then you override that with "Insert your choice." And the remaining arguments become the choices.What you want is:
I think you want to use
--text-entry
for the array of values, not--text
(reference). Using:I see the default value of the dropdown box pre-filled with the first value of array, and all values available.