Software:Zenity
Example of a Zenity dialog box | |
Original author(s) | Sun Microsystems |
---|---|
Developer(s) | Glynn Foster Lucas Rocha |
Operating system | Unix-like |
License | GNU Lesser General Public License |
Website | wiki |
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,[1] though it has fewer features than more complex GUI-creation tools.[2]
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[3]
Cross-platform compatibility
(As of 2012), Zenity is available for Linux, BSD and Windows.[4] 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. 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.[5]
Examples
Python example
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
#!/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
- GTK-server
- Dialog
- List of GNOME applications
References
- ↑ Cartwright, Ryan (2009-01-30), "More fun with Zenity: shell script/GUI interactivity", Free Software Magazine, http://www.freesoftwaremagazine.com/columns/saving_my_sanity_zenity_shell_script_interaction_gui, retrieved 2011-12-10
- ↑ Diehl, Mike (2008-05-12), "Make Your Scripts User Friendly with Zenity", LinuxJournal, http://www.linuxjournal.com/content/make-your-scripts-user-friendly-zenity, retrieved 2011-12-10
- ↑ Tyler, Chris (2006), "Chapter 4. Basic System Management", Fedora Linux, O'Reilly Media, pp. 258–259, ISBN 978-0-596-52682-5, http://proquest.safaribooksonline.com/0596526822/I_0596526822_CHP_4_SECT_12, retrieved 2010-03-15
- ↑ Zenity for Windows, http://www.placella.com/software/zenity/, retrieved 2011-12-10
- ↑ Ramos, Brian (2011-04-20), PyZenity, http://brianramos.com/?page_id=38, retrieved 2012-11-15
External links
Original source: https://en.wikipedia.org/wiki/Zenity.
Read more |