Zenity

Last updated
Zenity
Original author(s) Sun Microsystems
Developer(s) Glynn Foster
Lucas Rocha
Stable release
3.44.1 [1]   OOjs UI icon edit-ltr-progressive.svg / 28 April 2023;2 months ago (28 April 2023)
Repository
Operating system Unix-like
License GNU Lesser General Public License
Website wiki.gnome.org/Projects/Zenity

Zenity is free software and a cross-platform program that allows the execution of GTK dialog boxes in command-line and shell scripts.

Contents

Description

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]

Cross-platform compatibility

As of 2012, 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. 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. [6]

Examples

Python example

A Zenity infobox as displayed on GNOME 3 (Please press a button).png
fromPyZenityimportInfoMessagefromPyZenityimportQuestionfromPyZenityimportErrorMessagechoice=Question('Please press a button.')ifchoice:InfoMessage('You pressed Yes!')else:ErrorMessage('You pressed No!')

POSIX shell script example

#!/bin/shifzenity--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 gotoerror zenity --info --text="You pressed Yes!"gotoend:error zenity --error --text="You pressed No!":end

See also

Related Research Articles

HyperTalk is a discontinued high-level, procedural programming language created in 1987 by Dan Winkler and used in conjunction with Apple Computer's HyperCard hypermedia program by Bill Atkinson. Because the main target audience of HyperTalk was beginning programmers, HyperTalk programmers were usually called "authors" and the process of writing programs was known as "scripting". HyperTalk scripts resembled written English and used a logical structure similar to that of the Pascal programming language.

AppleScript is a scripting language created by Apple Inc. that facilitates automated control over scriptable Mac applications. First introduced in System 7, it is currently included in all versions of macOS as part of a package of system automation tools. The term "AppleScript" may refer to the language itself, to an individual script written in the language, or, informally, to the macOS Open Scripting Architecture that underlies the language.

In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin), standard output (stdout) and standard error (stderr). Originally I/O happened via a physically connected system console, but standard streams abstract this. When a command is executed via an interactive shell, the streams are typically connected to the text terminal on which the shell is running, but can be changed with redirection or a pipeline. More generally, a child process inherits the standard streams of its parent process.

<span class="mw-page-title-main">FLTK</span>

Fast Light Toolkit is a cross-platform widget library for graphical user interfaces (GUIs), developed by Bill Spitzak and others. Made to accommodate 3D graphics programming, it has an interface to OpenGL, but it is also suitable for general GUI programming.

<span class="mw-page-title-main">Graphical widget</span> Element of interaction in a graphical user interface

A graphical widget in a graphical user interface is an element of interaction, such as a button or a scroll bar. Controls are software components that a computer user interacts with through direct manipulation to read or edit information about an application. User interface libraries such as Windows Presentation Foundation, Qt, GTK, and Cocoa, contain a collection of controls and the logic to render these.

<span class="mw-page-title-main">PyQt</span> Python GUI library

PyQt is a Python binding of the cross-platform GUI toolkit Qt, implemented as a Python plug-in. PyQt is free software developed by the British firm Riverbank Computing. It is available under similar terms to Qt versions older than 4.5; this means a variety of licenses including GNU General Public License (GPL) and commercial license, but not the GNU Lesser General Public License (LGPL). PyQt supports Microsoft Windows as well as various kinds of UNIX, including Linux and MacOS.

An alert dialog box is a special dialog box that is displayed in a graphical user interface when something unexpected occurred that requires immediate user action.

<span class="mw-page-title-main">Fox toolkit</span>

The FOX toolkit is an open-source, cross-platform widget toolkit, i.e. a library of basic elements for building a graphical user interface (GUI). FOX stands for Free Objects for X.

wxPython Python wrapper for wxWidgets

wxPython is a wrapper for the cross-platform GUI API wxWidgets for the Python programming language. It is one of the alternatives to Tkinter. It is implemented as a Python extension module.

<span class="mw-page-title-main">PHP-GTK</span> PHP library for GTK+ GUI applications

PHP-GTK is a set of language bindings for the programming language PHP which allow GTK graphical user interface (GUI) applications to be written in PHP. PHP-GTK provides an object-oriented programming interface to GTK classes and functions. PHP-GTK partly supports GTK2, but GTK3 is unsupported.

The Linux Desktop Testing Project (LDTP) is an open-source testing tool that uses computer assistive technology to automate GUIs. The GUI functionality of an application can be tested in Windows, Mac, Linux, Solaris, FreeBSD and embedded environments. The Mac OS X version is called PyATOM, and the Windows version is Cobra.

Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit, and is Python's de facto standard GUI. Tkinter is included with standard Linux, Microsoft Windows and macOS installs of Python.

<span class="mw-page-title-main">Newt (programming library)</span>

Newt is a programming library for color text mode, widget-based user interfaces. Newt can be used to add stacked windows, entry widgets, checkboxes, radio buttons, labels, plain text fields, scrollbars, etc., to text user interfaces. This package also contains the shared library needed by programs built with newt, as well as an application whiptail, which provides the most commonly used features of dialog. Newt is based on the slang library. It abbreviates from Not Erik's Windowing Toolkit.

<span class="mw-page-title-main">Tk (software)</span> GUI toolkit or framework

Tk is a cross-platform widget toolkit that provides a library of basic elements of GUI widgets for building a graphical user interface (GUI) in many programming languages. It is free and open-source software released under a BSD-style software license.


The Wing Python IDE family of integrated development environments (IDEs) from Wingware was created specifically for the Python programming language, with support for editing, testing, debugging, inspecting/browsing, and error checking Python code.

<span class="mw-page-title-main">GNOME</span> Desktop environment for Linux and other Unix-like systems

GNOME, originally an acronym for GNU Network Object Model Environment, is a free and open-source desktop environment for Linux and other Unix-like operating systems.

<span class="mw-page-title-main">Kivy (framework)</span> Free and multi-platform graphical library for Python

Kivy is a free and open source Python framework for developing mobile apps and other multitouch application software with a natural user interface (NUI). It is distributed under the terms of the MIT License, and can run on Android, iOS, Linux, macOS, and Windows.

References

  1. Error: Unable to display the reference properly. See the documentation for details.
  2. Cartwright, Ryan (2009-01-30), "More fun with Zenity: shell script/GUI interactivity", Free Software Magazine , archived from the original on 2011-11-06, retrieved 2011-12-10
  3. Diehl, Mike (2008-05-12), "Make Your Scripts User Friendly with Zenity", LinuxJournal, archived from the original on 2011-11-26, retrieved 2011-12-10
  4. Tyler, Chris (2006), "Chapter 4. Basic System Management", Fedora Linux, O'Reilly Media, pp. 258–259, ISBN   978-0-596-52682-5, archived from the original on 2011-07-15, retrieved 2010-03-15
  5. Zenity for Windows, archived from the original on 2012-01-12, retrieved 2011-12-10
  6. Ramos, Brian (2011-04-20), PyZenity, archived from the original on 2013-10-07, retrieved 2012-11-15