Zenity Command-- Linux

Zenity Command-- Linux

No alt text provided for this image


What is Zenity ?

Zenity is a program that will display GTK+ dialogs, and return the user's input. This allows you to present information, and ask for information from the user, from all manner of shell scripts.

The application lets you create Graphical dialog boxes in the command line and makes the interaction between user and shell very easy.

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

Read more at: https://www.commandlinux.com/man-page/man1/zenity.1.html

Zenity Features :--

1. FOSS Software

2. Cross Platform Application

3. Allow GTK+ Dialog Box Execution

4. Command Line Tool

5. Support in Shell Scripting

Basic 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.

  • When you write scripts, you can use Zenity to create simple dialogs that interact graphically with the user, as follows:
  • You can create a dialog to obtain information from the user. For example, you can prompt the user to select a date from a calendar dialog, or to select a file from a file selection dialog.
  • You can create a dialog to provide the user with information. For example, you can use a progress dialog to indicate the current status of an operation, or use a warning message dialog to alert the user.

When the user closes the dialog, Zenity prints the text produced by the dialog to standard output.

Functions we can use in Zenity :--

1. Calendar :-

Syntax : [root@localhost ~]#zenity — calendar

No alt text provided for this image

Here we simply can see the calendar displayed into a dialogue box. Here we can select the date we want and we get that date as output .

Under option calendar there are many other options. We can put our own text by using option — text=”TEXT” and also set particular day or month or year and display it by default using options

— day=INT_DATE , — month=INT_MONTH , — year=INT_YEAR

No alt text provided for this image

Here, we have given text input as CALENDAR and set date using above mentioned options as 3/4/2002 and that date is displayed by default in our calendar.

2. Error :-

Syntax : [root@localhost ~]#zenity — error

No alt text provided for this image

Error dialogue box

We can also give title to this dialogue box and edit the text inside box as we did above.

3. Entry :-

Syntax : [root@localhost ~]#zenity — entry

No alt text provided for this image

Entry dialogue box

4. File-selection :-

Syntax : [root@localhost ~]#zenity — file-selection

When we simply use only file-selection option, we can select one file at a time.

No alt text provided for this image

Here we can select only one file .

If we ant to select multiple files then we can use option ‘— multiple’ to choose many files at a me.

No alt text provided for this image

We can choose multiple files at a time.

Also if we want a file to be selected by default then we can give name of file in option — filename=FILENAME

No alt text provided for this image

We gave name of the file and that file is selected by default.

5. Info :-

Syntax : [root@localhost ~]#zenity — info

This command option simply displays a dialogue box where we can display any text we want.

No alt text provided for this image

Here we can see that dialogue box is displayed.

We can specify the text and title of this dialogue box as we did previously.

No alt text provided for this image

Specifying the message to be displayed.

No alt text provided for this image

Adding title

6. List :-

Syntax : [root@localhost ~]#zenity — list column=COLUMN_NAME

We can display a list using list option and also first we have to make a column and give it name. Also we can display text using text option. Also we can pass the elements in list by specifying them into alternate way which is little difficult.

No alt text provided for this image

Creating one column

No alt text provided for this image

Creating two columns.

No alt text provided for this image

Adding elements in column.

No alt text provided for this image

Adding elements in two columns.

Also we can give check boxes and radio-list the elements in list :

No alt text provided for this image

Check-list.

No alt text provided for this image

Radio-list.

7. Notification :-

Syntax : [root@localhost ~]#zenity — notification

We have to simply use notification option and add the text to be displayed in notification using text option.

No alt text provided for this image

We displayed notification “THIS IS A NOTIFICATION”.

8. Progress :-

Syntax : [root@localhost ~]#zenity — progress

We can simply display a progress bar and some text above it using text option.

No alt text provided for this image

Progress bar with text.

Also we can specify the percentage in progress bar using option

— percentage=INT

No alt text provided for this image

Progress bar with percentage.

Also we can add the pulsation to progress bar using option , — pulsate

No alt text provided for this image

Progress bar with text and percentage and pulstation.

9. Question :-

Syntax : [root@localhost ~]#zenity — question

We can simply ask any question to user and specify question using text option.

No alt text provided for this image

Question.

10. Warning :-

Syntax : [root@localhost ~]#zenity — warning

We can specify warning to be displayed with text option,

No alt text provided for this image

Warning.

11. Scale :-

Syntax : [root@localhost ~]#zenity — scale

This option displays a scale bar where we can select a value,

No alt text provided for this image

Scale.

Also,we can specify text using text option and also we can specify default value by option , — value=INT . Also, we can set minimum and maximum values to be selected using options , — minimum=INT , — maximum=INT respectively. Also we can specify the steps by which value can be increased or decreased.

No alt text provided for this image

Scale with min value 10.

No alt text provided for this image

Scale with maximum range 90.

12. Colour Selection :-

Syntax : [root@localhost ~]#zenity — colour-selection

We can select the colour we want using this option.

No alt text provided for this image

Colour-selection.

13. Password :-

Syntax : [root@localhost ~]#zenity — password

This option simple collects our password,

No alt text provided for this image

Password.

14. Forms :-

Syntax : [root@localhost ~]#zenity — forms

This option opens up a form in which we can specify text,

No alt text provided for this image

Form.

To know more about zenity , use command man zenity .

Thank You!!!

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

Atishay Jain的更多文章

  • Funny Commands in Linux

    Funny Commands in Linux

    sl (Steam Locomotive): You might be aware of the command ‘ls’ in linux. It is used to view the contents of a folder.

  • Date Command in Linux

    Date Command in Linux

    The date command in linux is used to display the current time in the given format, or set the system time. Besides…

  • ESPEAK-NG COMMAND, LINUX

    ESPEAK-NG COMMAND, LINUX

    What is espeak-ng? The eSpeak NG is a compact open-source software text-to-speech synthesizer for Linux, Windows…

社区洞察

其他会员也浏览了