This article's lead section may be too short to adequately summarize the key points. (February 2013) |
| Zenity | |
|---|---|
Example of a Zenity dialog box | |
| Original author | Sun Microsystems |
| Developers | Glynn Foster Lucas Rocha |
| Stable release | |
| Operating system | Unix-like |
| License | GNU Lesser General Public License |
| Website | gitlab |
| Repository | |
Zenity is a free software and cross-platform computer program that allows the execution of GTK dialog boxes in command-line and shell scripts.
Like tools such as whiptail and dialog, Zenity allows easy creation of GUIs, though it has fewer features than more complex GUI-creation tools.
Other scripting languages such as Perl and Python can be used to construct full-scale GUI applications, but the zenity program enables a shell script to interact with a GUI user.... [The] user interface is not as refined as one that could be provided by a full-featured GUI application, but it is perfectly suitable for simple interactions.
— Chris Tyler
As of 2012[update], Zenity is available for Linux, BSD and Windows. A Zenity port to Mac OS X is available in MacPorts and Homebrew.
As of 2018, Zenity ports for Windows are available: zenity-windows (based on version 3.20.0) and winzenity (based on 3.8.0 / statically linked)
Zenity does not possess any built-in scripting capabilities and it must, therefore, rely on an interpreter for processing. One option is Python in combination with the PyZenity library.

from PyZenity import InfoMessage
from PyZenity import Question
from PyZenity import ErrorMessage
choice = Question("Please press a button.")
if choice:
InfoMessage("You pressed Yes!")
else:
ErrorMessage("You pressed No!")
#!/bin/sh
if zenity --question --text="Please press a button."; then
zenity --info --text="You pressed Yes\!"
else
zenity --error --text="You pressed No\!"
fi
@echo off
zenity --question --ok-label="Yes" --cancel-label="No" --text="Please press a button."
if %ERRORLEVEL% == 1 goto error
zenity --info --text="You pressed Yes!"
goto end
:error
zenity --error --text="You pressed No!"
:end
{{cite web}}: Missing or empty |title= (help)