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, though it has fewer features than more complex GUI-creation tools.Cross-platform compatibility
, 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: and
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.
Examples
Python example
from PyZenity import InfoMessage
from PyZenity import Question
from PyZenity import ErrorMessage
choice = Question
if choice:
InfoMessage
else:
ErrorMessage
POSIX shell script example
- !/bin/sh
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
zenity --error --text="You pressed No!"