LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   dialog --radiolist with list from file to choose not working (https://www.linuxquestions.org/questions/slackware-14/dialog-radiolist-with-list-from-file-to-choose-not-working-930774/)

wargus 02-22-2012 06:05 PM

dialog --radiolist with list from file to choose not working
 
Hello,

I am trying to write a dialog UI for a script I use to save me from typing infinite commands each time. Now I don't get this part of it to work:

There is a directory with several files. I create a list which contains *.gds files only, and I print only the name of them to the list.

Code:

ls -al $DIR | grep .gds | gawk -F ' ' '{print $9} > $LIST
I want to select one file at a time from this list, so I use the
Code:

dialog --radiolist
option. I think I've understood everything written in the manpage about dialog, but this isn't explained there. I've tried to number each line so I get a tag for each file to select, I've added the off/on statement for default setting of the radiobutton, I've tried several things with the --file option... I've checked how others do it (pkgtool, sbopkg and such scripts which use dialog together with lists) but I don't get it (it's too complex there for me to figure out). I've checked the format of the input file to dialog in the remove part of pkgtool and tried like this, no success.

I still think it's a formatting problem of my list.
Any ideas how this should be done?

Thank you

corp769 02-22-2012 06:14 PM

For the radiolist option, it should something as such:
Code:

dialog --backtitle "Test" --radiolist "Select option:" 15 35 3 \
 1 "Test 1" off \
 2 "Test 2" on \
 3 "Test 3" off

I broke it up into sections to better understand. The 15 and 35 are height and width, respectively, the first 3 is how many options in your radio list, and then you can probably figure the rest out.

Cheers,

Josh

wargus 02-22-2012 06:46 PM

OK, I tried it out again and put following to a file

Code:

1 "Test 1" off \
 2 "Test 2" on \
 3 "Test 3" off

then with

Code:

dialog --backtitle "Test" --radiolist "Select option:" 15 35 3 \
 --file $OPTIONS_FILE

and it works :scratch: it also works after I rewrote my create_list( ) :scratch:
Seems I tried too long last night and messed up something with my list and the format was not proper. I should go to sleep earlier :rolleyes:

Thank you very much, I should have figured out myself

:hattip:

corp769 02-22-2012 11:21 PM

Honestly, I would have gone another route, but hey, if that works, and you understand it, then by all means use it. Cheers though on figuring it out!

Josh

wargus 02-23-2012 03:30 AM

Could you please enlighten me :Pengy:


:hattip:

corp769 02-23-2012 05:04 AM

Sure thing. I am leaving to go home soon from work, so sometime later on I will get on and explain by what I mean.

Cheers!

PDock 02-24-2012 06:05 AM

Hi wargus. Here is an old post of mine which seems on topic with your concept: http://www.linuxquestions.org/questi...ove%5D-378279/

Care to post your final script here.
ppd

wargus 02-24-2012 01:08 PM

Hi PDock

well I simply try to create a UI for a script which generates a 3D view from a gds-file (microchip layout). The command needs many arguments each time and it's annoying to type them every time. Additional to the gds-file it needs two special files, depending on the technology used in the gds. So I make the user chose it one by one, but I don't like the --fselect dialog so I was to list the content of a directory and pass it to the --radiolist dialog. At the end I messed up the format of the input file.

I am teaching myself shell scripting and any input from other scripts is welcome, to learn and steal a bit :p Mostly, big scripts are not easily readable for me because of the many nested variables they contain and the lack of in-script documentation.

Keith Hedger 02-25-2012 05:50 AM

Instead of writing your options to a tmp file why not use a variable like this
Code:

echo $DIALOGDATA|xargs dialog --separate-output --checklist "Select Tags To Change" 0 0 0
This is a snippet from a cdripping script that needs a variable length checklist, $DIALOGDATA contains the options for each check button ( 1 "Test 1" off ... in your example above .
P.S.
quotes should be escaped like so
Code:

DIALOGDATA="1 \"Test 1\" off 2 \"Test 2\" on 3 \"Test 3\" off"

wargus 02-25-2012 02:58 PM

Thank you KH for the input, I need to learn about xargs anyway earlier or later...


:hattip:


All times are GMT -5. The time now is 06:12 PM.