Zenity — Creates Graphical (GTK+) Dialog Boxes in Command-line

Lalita Rajpoot
5 min readSep 18, 2021

--

Linux is an open source operating system. Like other operating system (such as Windows) Linux consists of various software components that manage computer hardware resources and enable you to do tasks such as surfing the web or editing a file in a text editor.

Linux is a free and open source software, which means that you can use, copy, study, and change the software in any way. It is distributed with the source code so users can view and modify it. This is in contrast to Microsoft Windows, a proprietary operating system.

Today, Linux runs almost every computing platform available: mobile phones, tablets, servers, desktops, mainframes, etc. Android, a widely used operating system for mobile phones and tablets is based on the Linux kernel.

Here in this article we will be discussing creation and execution of simple Graphical Dialog box using GTK+ application called “Zenity“.

What is Zenity?

Zenity is an open source and a cross-platform application which displays GTK+ Dialog Boxes in command-line and using shell scripts. . It allows to ask and present information to/from shell in Graphical Boxes. The application lets you create Graphical dialog boxes in command-line and makes the interaction between user and shell very easy.

Zenity Features

  1. FOSS Software
  2. Cross Platform Application
  3. Allow GTK+ Dialog Box Execution
  4. Command Line Tool
  5. Support in Shell Scripting

Usefulness

  1. Easy GUI Creation
  2. Less features than other complex Tools
  3. Enables shell scripts to interact with a GUI users
  4. Simple dialog creation is possible for graphical user interaction

Installation of Zenity in Linux

Zentity is by default installed or available in repository of most of the Standard Linux distribution of today. You can check if is installed onto your machine or not by executing following commands.

Zenity Basic Dialog Boxes

Some of the basic Dialogs of Zenity, which can be invoked directly from the command-line.

  1. How about a quick calendar dialog?

2. An error Dialog Box

Error dialog box

3. A General text Entry Dialog Box

Entry dialog box

4. An Information Dialog

Information dialog

5. A question Dialog box

6. A progress Bar

7. Scale Dialog

8. A Password Dialog

9. A Form Dialog box

10. Create Shell Script Dialog

Now we would be discussing Zenity Dialog creation using simple shell scripts here. Although we can create single Dialog by executing Zenity commands directly from the shell but then we can’t link two Dialog boxes in order to obtain some meaningful result.

How about an interactive dialog box which takes input from you, and shows the results

In the below line ‘first’ is a variable and the value of variable is Generated at run time.

  1. –entry‘ means zenity is asked to generate an text Entry box.
  2. – title=‘ defines the title of generated text box.
  3. — text=‘ defines the text that is available on text Entry box.

This line of the below script file is for generation of Information (–info) Dialog box, with title “Hi” and Text “Mr./Ms.first”

Thanks:)

--

--