I am creating a menu with the linux utility dialog (see below) and I have heard that it is possible to make a tree-like structure for those checklists. However I cannot find any type in the manpage that creates such a thing? Is it really possible - and if yes: how? See http://i51.tinypic.com/2ir9qfl.png vs http://i56.tinypic.com/35jasmh.png for how it actually looks like and how it should look like. The original pic was created using dialog --checklist.
First and foremost thank you for the answerz. However the ambiguity of the word 'dialog' and the lack of a correct side by side comparison (couldn't double-check as I was unexpectedly hurried - sorry) made the question difficult to understand.
Hope this helps: How it looks like: http://i51.tinypic.com/2ir9qfl.png
How it should look like: http://i56.tinypic.com/35jasmh.png
I still want to use the 'dialog' 开发者_如何学JAVAutility - I just want a tree-like view that shows that allows to group some items for better overview. It should be the front-end for a rather complex script that can checkout, compile, fetch and do some other fancy stuff, and the person who wanted me to do this script said that he is sure a tree-like view in dialog is possible as he had seen it before, could however not supply me with the necessary code.
You cannot use the Linux dialog utility to do a single page checklist hierarchy
Instead, create a series of menus to achieve the same semantic structure, far from optimal though, I'll grant you.
The other option is to write a script (in perl/python/ruby perhaps) which uses the ncurses/curses library to build this section of the UI. See here (python example) to help you get started.
Note.
The person who said they had seen a tree like view composed in dialog has either...
- Seen it done with a patched/non-standard version of dialog which may exist. (?!)
- Saw a custom made ncurses/curses app that provided a similar UI to dialog, hence the confusion.
For more info on ncurses/curses see http://www.linuxselfhelp.com/HOWTO/NCURSES-Programming-HOWTO/
The sample you posted will be difficult to match in formatting, but bash/ksh/zsh all support the select
construct, which builds a menu and allows you to process the results of the selection.
PS3="Choose an option "
select opt in start mid end quit
do
case $opt in
start) echo "starting";;
mid) echo "Standing by";;
end) echo "Standing by";;
quit) break;;
esac
done
Example run
1) start
2) mid
3) end
4) quit
Choose an option
1
starting
4
# prompt >
Depending on your requirments, you may need to wrap this a continuous loop, i.e.
while true ; do
select ...
done
I don't think it will be possible to center the question tree as your example.
I hope this helps.
P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.
精彩评论