{{Short description|Free software for dialog boxes}} {{lead too short|date=February 2013}} {{Infobox software | title = Zenity | logo = | screenshot = A Zenity infobox as displayed on GNOME 3 (Fedora 17).png | screenshot size = 255px<!--Native size--> | caption = Example of a Zenity dialog box | collapsible = | author = Sun Microsystems | developer = Glynn Foster<br />Lucas Rocha | released = | latest release version = {{wikidata|property|edit|reference|P348}} | latest release date = {{start date and age|{{wikidata|qualifier|P348|P577}}}} | programming language = | operating system = Unix-like | platform = | size = | language = | genre = | license = GNU Lesser General Public License | website = {{URL|https://gitlab.gnome.org/GNOME/zenity}} }}
'''Zenity''' is a free software and cross-platform computer program that allows the execution of GTK dialog boxes in command-line and shell scripts.
== Description == Like tools such as whiptail and dialog, Zenity allows easy creation of GUIs,<ref name="fsm-more-fun"/> though it has fewer features than more complex GUI-creation tools.<ref name="lj-zenity-friendly"/>
{{Blockquote | 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<ref name="Tyler"/> }}
== Cross-platform compatibility == {{As of|2012}}, Zenity is available for Linux, BSD and Windows.<ref name="placella"/> A Zenity port to Mac OS X is available in MacPorts and Homebrew.
As of 2018, Zenity ports for Windows are available: [https://github.com/kvaps/zenity-windows/ zenity-windows] (based on version 3.20.0) and [https://github.com/maravento/vault/tree/master/winzenity 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.<ref name="brianramos"/>
== Examples ==
=== Python example === right
<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 == {{Portal|Free and open-source software}} * GTK-server * Dialog * List of GNOME applications
==References== {{Reflist|refs= <ref name="fsm-more-fun">{{citation | url = http://www.freesoftwaremagazine.com/columns/saving_my_sanity_zenity_shell_script_interaction_gui | title = More fun with Zenity: shell script/GUI interactivity | first = Ryan | last = Cartwright | work = Free Software Magazine | date = 2009-01-30 | access-date = 2011-12-10 | archive-url = https://web.archive.org/web/20111106084405/http://www.freesoftwaremagazine.com/columns/saving_my_sanity_zenity_shell_script_interaction_gui | archive-date = 2011-11-06 | url-status = live}}</ref> <ref name="lj-zenity-friendly">{{citation | url = http://www.linuxjournal.com/content/make-your-scripts-user-friendly-zenity | title = Make Your Scripts User Friendly with Zenity | first = Mike | last = Diehl | work = LinuxJournal | date = 2008-05-12 | access-date = 2011-12-10 | archive-url = https://web.archive.org/web/20111126003613/http://www.linuxjournal.com/content/make-your-scripts-user-friendly-zenity | archive-date = 2011-11-26 | url-status = live}}</ref> <ref name="Tyler">{{citation | chapter-url = http://proquest.safaribooksonline.com/0596526822/I_0596526822_CHP_4_SECT_12 | title = Fedora Linux | chapter = Chapter 4. Basic System Management | last = Tyler | first = Chris | publisher = O'Reilly Media | year = 2006 | isbn = 978-0-596-52682-5 | pages = 258–259 | access-date = 2010-03-15 | archive-url = https://web.archive.org/web/20110715224511/http://proquest.safaribooksonline.com/0596526822/I_0596526822_CHP_4_SECT_12 | archive-date = 2011-07-15 | url-status = live}}</ref> <ref name="placella">{{citation | url = http://www.placella.com/software/zenity/ | title = Zenity for Windows | access-date = 2011-12-10 | archive-url = https://web.archive.org/web/20120112170727/http://www.placella.com/software/zenity/ | archive-date = 2012-01-12 | url-status = dead}}</ref> <ref name="brianramos">{{citation | url = http://brianramos.com/?page_id=38 | title = PyZenity | first = Brian | last = Ramos | date = 2011-04-20 | access-date = 2012-11-15 | archive-url = https://web.archive.org/web/20131007155326/http://brianramos.com/?page_id=38 | archive-date = 2013-10-07 | url-status = live}}</ref> }}
==External links== * {{Official website|https://help.gnome.org/users/zenity/stable/}}{{Dead link|date=April 2026}}
{{GNOME}}
Category:GNOME Applications Category:GNOME Developer Tools Category:GTK Category:Sun Microsystems software
{{free-software-stub}}