![]() | This article has multiple issues. Please help improve it or discuss these issues on the talk page . (Learn how and when to remove these messages)
|
Zenity | |
---|---|
![]() Example of a Zenity dialog box | |
Original author(s) | Sun Microsystems |
Developer(s) | Glynn Foster Lucas Rocha |
Stable release | |
Repository | |
Operating system | Unix-like |
License | GNU Lesser General Public License |
Website | gitlab |
Zenity is free software and a cross-platform 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, [2] though it has fewer features than more complex GUI-creation tools. [3]
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 [4]
As of 2012 [update] , Zenity is available for Linux, BSD and Windows. [5] 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. It is found that for the creation of 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. [6]
fromPyZenityimportInfoMessagefromPyZenityimportQuestionfromPyZenityimportErrorMessagechoice=Question("Please press a button.")ifchoice:InfoMessage("You pressed Yes!")else:ErrorMessage("You pressed No!")
#!/bin/shifzenity--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 gotoerror zenity --info --text="You pressed Yes!"gotoend:error zenity --error --text="You pressed No!":end