[SOLVED] GUI for multi-line text input for bash script

Need help with C, C++, perl, python, etc?

[SOLVED] GUI for multi-line text input for bash script

Postby hiltuspeke » 2016-11-16 15:45


I've written very simple bash script to read user input for a variable and then echo that variable to a text file for later use.

I want this script to work on a graphical interface without a terminal window, so currently I'm using Zenity to read the input. It is working marvelously, but the text entry dialog in Zenity only has one line. I need to have a input dialog that allows me to input a string of text with line breaks in it. I couldn't find a way around this in the documentation of Zenity, which leaves me to the conclusion it simply is not possible with Zenity.

Is there another, similar software I could use? Of course there is dialog, but as mentioned, I'd like to stay graphical. I found some ~10 years old discussion online about this very same issue, and they recommended using gtkdialog, but I can't find it in the repos anymore.

And yes, I could theoretically just add -e -switch for echo in my script and use \n instead of enter when writing the input, but that is far from easy-to-use and minimalism I'm aiming for.

What should I use?
Last edited by hiltuspeke on 2016-11-17 18:17, edited 1 time in total.
Posts: 13
Joined: 2016-11-14 18:37

Re: GUI for multi-line text input for bash script

Postby alan stone » 2016-11-17 11:01

Did you have a look here and here?
Debian GNU/Linux 8.8 (jessie)
wm: openbox

If you need initiation of coercion, force, violence to enforce your idea or theory, or if every single time it is applied to the real world it fails completely, your idea or theory sucks and is worthless.
User avatar
alan stone
Posts: 132
Joined: 2011-10-22 14:08
Location: In my body.

Re: GUI for multi-line text input for bash script

Postby kiyop » 2016-11-17 14:33

Yad and so on may be good.
Code: Select all
# PREPARATION - install dialog and xterm
apt update
apt install dialog xterm

xterm -e "dialog --editbox /PATH/TO/FILE 0 0"

ADDED AT Sat Nov 19 13:03:57 JST 2016;

Thank hiltuspeke for telling the option "--text-info --editable" :)
Last edited by kiyop on 2016-11-19 04:06, edited 1 time in total.
Openbox, JWM: Jessie, Sid, Arch / Win XP (on VirtualBox), 10
User avatar
Posts: 3984
Joined: 2011-05-05 15:16
Location: Where persons without desire to improve themselves fear to tread, in Japan

Re: GUI for multi-line text input for bash script

Postby hiltuspeke » 2016-11-17 18:10

It turned out that this is indeed possible in Zenity.

I found it out while reading the documentation for YAD.
In YAD it is possible to input many lines using Text-info dialog and mark it editable:
Code: Select all
--text-info --editable

After this success in YAD I tried the very same syntax for Zenity, and it indeed is possible with the very same syntax. Case closed.
(Now that I have YAD compiled, I may still stick to that, as it uses GTK+2 and looks nicer on my Mate setup. )
Posts: 13
Joined: 2016-11-14 18:37

Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests