In this article, I will introduce the rest of zenity, which is to create a text information dialog. This will help you create dialogs that display information from a text file. Normally, you will see dialog boxes displaying copyright information while installing certain software.
Creates a text information dialog
Table of Contents
To create a text information dialog, use the zenity command with the --text-info
option:
zenity --text-info
A blank dialog will appear.
If you just use the above then it seems to have no idea what for us. Now we see the other options supported for text-info. Using these new options really helps you do something.
Text info options
The following table lists the support options:
Option | Meaning |
--filename=FILENAME | The path to the file you want to display its content in the dialog. For example: /home/danie/Desktop/test.txt |
--editable | Allows you to edit text content when displayed in the dialog box. The edit information will be returned in the command window, not saved to the original text file. You can scale the dialog box using this option. You can try using and do not use this option. |
--font=FONT | Select the font to display the text in the dialog box. I rarely use this option. |
--checkbox=TEXT | Activate the checkbox in the text box as text “I have read and agree to the policies”. |
--html | Supports displaying html code in text file to dialog box. |
--url=URL | Use url path instead of filename. This option is only available when using --html . I have not tried this option, you can try it. |
Below, I will open a text file that I created earlier. In that text file, I write simple content that includes a little html code.
Read more: Display text in a message dialog.
I will use the following command to create a text information dialog and display content that does not support html.
zenity --text-info --title="WriteBash.com - demo text-info dialog" --filename=/home/danie/Desktop/test.txt --editable
Next, I use the command with the html support option, let’s see how the results.
zenity --text-info --title="WriteBash.com - demo text-info dialog" --filename=/home/danie/Desktop/test.txt --editable --html
The remaining options, please try your own and experience how the results.
Conclusion
With just a few simple lines of code, you can create a text information dialog, in a very simple way. Using your imagination, you can use it in many different situations.
(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).