Zenity
| Company type | Free and open-source software |
|---|---|
| Industry | Software development |
Area served | Cross-platform (Linux, BSD, Windows, Mac OS X) |
| Products | GTK dialog boxes for command-line and shell scripts |
| Website | help |
Zenity is a free and open-source application designed to run GTK dialog boxes from within command-line environments and shell scripts, functioning across multiple operating systems.
Description
Zenity, comparable to utilities such as whiptail and dialog, simplifies the process of generating graphical user interfaces,[1] although it provides a more limited feature set relative to comprehensive GUI development tools.[2]
Cross-platform compatibility
By 2012, Zenity was compatible with Linux, BSD variants, and Windows platforms.[3] Users can also access Mac OS X versions through package managers like MacPorts and Homebrew.
As of 2018, Windows distributions include zenity-windows, derived from version 3.20.0, and winzenity, based on version 3.8.0 with static linking.
Zenity itself does not incorporate native scripting functions and relies on an external interpreter to operate. For scripts intended to run cross-platform with minimal adjustments, it is advisable to use interpreters broadly supported across systems—such as Python paired with the PyZenity module.[4]
Python example
<syntaxhighlight lang="python"> 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!")
</syntaxhighlight>
POSIX shell script example
<syntaxhighlight lang="bash">
- !/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 </syntaxhighlight>
Windows shell script example
<syntaxhighlight lang="dosbatch"> @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
</syntaxhighlight>
See also
External links
- ↑ Cite error: Invalid
<ref>tag; no text was provided for refs namedfsm-more-fun - ↑ Cite error: Invalid
<ref>tag; no text was provided for refs namedlj-zenity-friendly - ↑ Cite error: Invalid
<ref>tag; no text was provided for refs namedplacella - ↑ Cite error: Invalid
<ref>tag; no text was provided for refs namedbrianramos