bashuser-interfacezenity

zenity dialog window with two buttons but no text entry


I would like to create a zenity dialog window with two buttons as only user input.

The following creates a window with two buttons but with a space for a text entry

zenity --entry --title="" --text "Choose A or B" --ok-label="B" --cancel-label="A"

The following creates a window with one button only

zenity --info --title="" --text "Choose A or B" --ok-label="B"

Solution

  • --question is what you are looking for:

    zenity --question \
    --title="" \
    --text "Choose A or B" \
    --ok-label="B" \
    --cancel-label="A"
    

    You may also try:

    zenity --question \
    --text="Choose A or B" \
    --switch \
    --extra-button "A" \
    --extra-button "B"
    

    This automatically generates a dialog with just your two extra buttons. (--switch suppresses the default OK and Cancel buttons)