Zenity: Red Hat Enterprise Linux 8.4

Zenity: Red Hat Enterprise Linux 8.4

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.

There are other alternatives,?but nothing compares to the simplicity of?Zenity, specially when you don’t need complex programming. Zenity, a tool you must have your hands on.

Zenity Features

1.???FOSS Software

2.???Cross Platform Application

3.???Allow GTK+ Dialog Box Execution

4.???Command Line Tool

5.???Support in Shell Scripting

Uses of Zenity

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

Since?Zenity?is available for all known major platforms, and based on GTK+ library, Zenity program can be ported to/from another platform.

By using Zenity, we can create GUI boxes for the following:

Calendar

File selection

Forms

List

Notification icon

Message

Error

Information

Question

Warning

Password entry

Progress

Text entry

Text information

Scale

Color selection

The entry widget

The entry widget is useful when we need to ask the user for some text. Say for example we need to ask the user to enter its name; we can run the following command:

zenity --entry --title "Name request" --text "Please enter your name:"        
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

File selection widget

The file selection widget let us display a nice graphical interface to let the user select one or more files. Just as we did in the previous examples, we can use a series of options to modify the behavior and appearance of the dialogue. One of the most important one is?--filename?which can be used to set the file/directory that will be selected by default.?

zenity --file-selection --multiple --filename "${HOME}/"        
No alt text provided for this image
No alt text provided for this image

If we open the dialogue in?save mode, the user will be asked to provide the name of the file he wants to save. If the file exists and we provided the?--confirm-overwrite?option, he will be prompted to confirm he wants to overwrite it:

zenity --file-selection --save --confirm-overwrite --filename "${HOME}/"        
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

The progress widget

#!/bin/bash
# Dummy script to demonstrate the zenity progress widget!
(
? echo 25
? echo "# Setting up..."
? sleep 2

? echo 30
? echo "# Reading files..."
? sleep 2

? echo 70
? echo "# Creating content..."
? sleep 1

? echo 100
? echo "# Done!"
) | zenity --title "Progress bar example" --progress --auto-killh        
No alt text provided for this image
No alt text provided for this image

Info, warning and error widgets

The notification widget

zenity --info --width=400 --height=200 --text "This is a notification!"        
No alt text provided for this image

The warning widget:

?zenity --warning --width=400 --height=200 --text "This is a warning!"        
No alt text provided for this image

The error widget:

zenity --error --width=400 --height=200 --text "This is an error!"        
No alt text provided for this image

The question widget

zenity --question --text "Are you sure you want to quit?" --no-wrap --ok-label "Yes" --cancel-label "No"        
No alt text provided for this image

The color selection widget

zenity --color-selection --color red --show-palette        
No alt text provided for this image



Vishu G.

DevOps Engineer@Devtron Inc (?????????) || Kubernetes || Cloud || Trainer || ?? 7K+ Followers ?? || Job Support || AWS || Ansible || Docker || Jenkins || Terraform

3 年
回复
Keyur B.

Senior DevOps Engineer at Crest Data Systems

3 年

Nice Work !!

回复
Shobhit Sharma

Combating FinCrime @ Airtel, Ex-Paytm

3 年

great work :)

回复

要查看或添加评论,请登录

Anudeep Nalla的更多文章

社区洞察

其他会员也浏览了