I want to use Xdialog, checklist box option in a script but need some help with the construction thereof. Simple example of what I want:
tag1=1 item1=john status=off
tag2=2 item2=peter status=off
If I select john from the list, the command cp /a.txt /root must be executed.
If I select peter, cp /b.txt /root must be executed.
If I select both from the list, the command for each item must be executed seperately (in other words john and its command, followed by peter and its command).
Thanks
Xdialog: checklist box option
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Try
Code: Select all
ANSWER=$(Xdialog --stdout --checklist "Select one or more" 0 0 6 "1" "John" "off" "2" "Peter" "off")
case /$ANSWER/ in
*/1/*) echo cp a.txt /root ;;&
*/2/*) echo cp b.txt /root ;;
esac
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
- Moose On The Loose
- Posts: 965
- Joined: Thu 24 Feb 2011, 14:54
BTW:nic007 wrote:Oh, okay. I was using Racy. Works with the newer Puppys. Thanks.
I find that if you make the "6" number one more than the number of items, the script looks much better.
If there are So many that the dialog box will be over about 400 pixels tall make the number at least two less than the actual number and also small enough that it comes in under 400. Some people, like me when traveling, are using a machine with a very limited screen.
Yes that number is for the space allocated for items in the list. On the average laptop screen about 20 items will fill the screen from top to bottom. But - there should be a scrollbar if you have more items.Moose On The Loose wrote:BTW:nic007 wrote:Oh, okay. I was using Racy. Works with the newer Puppys. Thanks.
I find that if you make the "6" number one more than the number of items, the script looks much better.
If there are So many that the dialog box will be over about 400 pixels tall make the number at least two less than the actual number and also small enough that it comes in under 400. Some people, like me when traveling, are using a machine with a very limited screen.
- Moose On The Loose
- Posts: 965
- Joined: Thu 24 Feb 2011, 14:54
Yes, I knew that. My advice was based on that and the fact that the "average screen" is very like the "average person". There is none that is actually the average. The 400 Pixels size was based on the idea that it is the size of a small screen that may be used. We want our programs to be accessible to all so we should be designing around the most limited case that is reasonable.nic007 wrote:Yes that number is for the space allocated for items in the list. On the average laptop screen about 20 items will fill the screen from top to bottom. But - there should be a scrollbar if you have more items.Moose On The Loose wrote:BTW:nic007 wrote:Oh, okay. I was using Racy. Works with the newer Puppys. Thanks.
I find that if you make the "6" number one more than the number of items, the
The "two less" bit in my advice is because a scrolling window that is just slightly smaller than the list makes a scroll bar that looks a bit wrong. With a bar nearly the full height of the scroll range, if fakes some people out and they seem not to see that it is a scroll bar. I had this happen with something I created for a "non-linux user". I made a bootable CD that did the thing they needed but that one point messed them up.