Zenity

{{short description|Free software that allows the execution of GTK dialog boxes in command-line and shell scripts}}

{{multiple issues|

{{lead too short|date=February 2013}}

{{how-to|date=February 2013}}

}}

{{Infobox software

| title = Zenity

| logo =

| screenshot = A Zenity infobox as displayed on GNOME 3 (Fedora 17).png

| screenshot size = 255px

| caption = Example of a Zenity dialog box

| collapsible =

| author = Sun Microsystems

| developer = Glynn Foster
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 free software and a cross-platform 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, though it has fewer features than more complex GUI-creation tools.

{{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

}}

Cross-platform compatibility

{{As of|2012}}, 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: [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. To create a script that runs on more than one platform without extensive modifications, it would be best to use an interpreter that is available on the widest range of operating systems. One option is Python in combination with the PyZenity library.

Examples

= Python example =

right

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!')

= POSIX shell script example =

  1. !/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

= Windows shell script example =

@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

See also

{{Portal|Free and open-source software}}

References

{{Reflist|refs=

{{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}}

{{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}}

{{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}}

{{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}}

{{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}}

}}