Zenity

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Zenity
Original authorSun Microsystems
DevelopersGlynn Foster
Lucas Rocha
Repository
  • {{URL|example.com|optional display text}}Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
Engine
    Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
    Operating systemUnix-like
    LicenseGNU Lesser General Public License
    Websitegitlab.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

    [edit | edit source]

    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

    [edit | edit source]

    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. 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.[5]

    Examples

    [edit | edit source]

    Python example

    [edit | edit source]
    File:A Zenity infobox as displayed on GNOME 3 (Please press a button).png
    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

    [edit | edit source]
    #!/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

    [edit | edit source]
    @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

    [edit | edit source]

    Lua error in mw.title.lua at line 392: bad argument #2 to 'title.new' (unrecognized namespace name 'Portal').

    References

    [edit | edit source]
    1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    5. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    [edit | edit source]