8

I'm using Kubuntu 18.04 with:

$ zenity --version
3.28.1

I want to display a --list dialog with zenity, but I don't want to show the Cancel button (in fact I'm okay if there is no OK either). It should be easy with the --no-cancel option:

$ zenity --list --no-cancel
--no-cancel is not supported for this dialog

The output seems to indicate that zenity knows about the option but does not want to let me use it.

I only want to show the user the data in a table. I don't care about selection/editing or getting a result back.

Is there any alternative way? Or is zenity simply unable to do this?

8

Yes, zenity is pretty limited. Luckily there’s a fork available which fills the gap: yad – “Yet Another Dialog” (sudo apt install yad). It uses the same syntax as zenity, but adds a ton of useful options, for example --button to explicitly define the buttons of your dialog window:

yad --list --button=OK:0

This displays a list window with just an “OK” button returning the exit code 0.

Example

Here’s a simple example inspired by one from the manpage:

yad --list --button=OK:0 --checklist --column "Buy" --column "Item" \
  TRUE Apples TRUE Oranges FALSE Pears FALSE Toothpaste

yad usage example

When “OK” is clicked in this state the program returns a 0 exit code and prints the checked options to stdout:

TRUE|Apples|
TRUE|Oranges|

Further reading

7

Relabel Zenity Cancel button

You can relabel the button but you can't remove it:

$ zenity --list --cancel-label="Go Back" --column="Column 1"

Will give you:

zenity cancel relabel.png


YAD (Yet Another Dialog)

Both yad and zenity allow you to use GUI dialog boxes from a bash script or the shell command line. Yad surpasses Zenity in every department though:

sudo apt install yad

Works in all distros.


Yad Progress bars

yad progress bars.png

You can define multiple progress bars in yad where zenity only offers 1. You can also include scrolling text.


Yad buttons

yad buttons.png

You can assign any text you want to any button. Also notice you can include a Window icon too.


Yad text entry

yad text entry.png

Yad displays text for you to change. Zenity cannot display existing text you can only enter new text.


Yad support

The author of Yad and many more contributors answer your questions in google groups. I've posted four or five questions about advanced functionality and usually get an answer within 24 hours. Not to mention enhancements are provided through the same channel.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.