Bash form with two columns

0

This script creates a form in a terminal window with one column and four rows. How can I create a form with two columns and two rows?

shell=""
groups=""
user=""
home=""
exec 3>&1
VALUES=$(dialog --ok-label "Submit" \
          --title "Useradd" \
          --form "User form" \
15 50 0 \
        "Username:" 1 1 "$user"         1 10 10 0 \
        "Shell:"    2 1 "$shell"        2 10 10 0 \
        "Group:"    3 1 "$groups"       3 10 10 0 \
        "HOME:"     4 1 "$home"         4 10 10 0 \
2>&1 1>&3)

exec 3>&-

This script produces:

a form with one column and four rows

I would prefer this arrangement of the input fields:

a form with two columns and two rows

I have tried to add a second --form option, but it didn't work.  I also have tried to add a second input field on the same row, but starting after the first, like this:

    "Second field:" 1 41 "$second"      1 10 10 0 \

It creates two headers, on the same row, but only one input field – on the next row.

John22

Posted 2017-04-25T21:22:29.020

Reputation: 23

If you're having trouble understanding the man page you could also check this. Which does have an information about how the fields are defined [ label y x item y x flen ilen ].

– Seth – 2017-04-27T08:59:26.823

Answers

0

If you read the man page for dialog, you’ll see that you must specify the Y and X coordinates for the fields and also, independently, for the field labels.  In your unsuccessful attempt, you moved the label into a (potential) second column, but you left the field in the first column.  I changed the field definition block to

            "Username:" 1  1 "$user"         1 10 10 0 \
            "Shell:"    2  1 "$shell"        2 10 10 0 \
            "Group:"    1 25 "$groups"       1 34 10 0 \
            "HOME:"     2 25 "$home"         2 34 10 0 \

(note that I’ve increased both the field X coordinate and the label X coordinate for “Group:” and “HOME:”).  This produces

    dialog form with two columns and two rows

which is essentially what you asked for.

Scott

Posted 2017-04-25T21:22:29.020

Reputation: 17 653