Results 1 to 3 of 3

Thread: Need dialog --column-separator example

  1. #1
    Join Date
    Mar 2009
    Beans
    51

    Need dialog --column-separator example

    While there are lots of tutorials and references to the tha man page explaining the syntax of the --column-separator option for dialog --menu, I can't find any examples that use it, nor can I make it work in my own code. The man page says

    Code:
    --column-separator <string>
    but I can't figure out whether <string> should be wrapped in quotes, and where and how it should be inserted in the menu definition. This works:

    Code:
    #!/bin/bash
    
        dialog --title " Welcome to My Menu! " \
               --menu "" 19 40 12              \
                       "1" "Option One"        \
                       "2" "Option Two"        \
                       "3" "Option Three"      \
                       "4" "Option Four"       \
    2>temp
    Cancelled=$?
    Choice=`cat temp` ; rm temp
    if [ $Cancelled -eq 0 ] 
      then echo "You selected: $Choice"
      else echo "You cancelled!"
    fi
    But when I try to add a column separator:

    Code:
    #!/bin/bash
    
        dialog --title " Welcome to My Menu! " \
               --column-separator "@"          \
               --menu "" 19 40 12              \
                       "1" "Option One"        \
                       "2" "Option Two"        \
    "@"                "3" "Option Three"      \
                       "4" "Option Four"       \
    2>temp
    Cancelled=$?
    Choice=`cat temp` ; rm temp
    if [ $Cancelled -eq 0 ] 
      then echo "You selected: $Choice"
      else echo "You cancelled!"
    fi
    It fails. Can someone provide me with an example? Thanks.

    --Nathanael

  2. #2
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,125
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Need dialog --column-separator example

    --column-separator is only for radio or "check boxes" which, I believe is the same as the documented checklist boxes... so maybe that option isn't usable in the way youre attempting.
    heres a article i liked:
    http://www.linuxjournal.com/article/2807

    Also, when I ran the second bit of code, option one showed "nfo"
    after it. I took out the floating "@"
    Im not sure if nfo is some sort of error code.


    Code:
    #!/bin/bash
    
        dialog --title " Welcome to My Menu! " \
               --column-separator "@"          \
               --menu "" 19 40 12              \
                       "1" "Option One"        \
                       "2" "Option Two"        \
                       "3" "Option Three"      \
                       "4" "Option Four"       \
    2>temp
    Cancelled=$?
    Choice=`cat temp` ; rm temp
    if [ $Cancelled -eq 0 ] 
      then echo "You selected: $Choice"
      else echo "You cancelled!"
    fi
    Last edited by conradin; September 11th, 2012 at 12:41 AM. Reason: also
    ~Conradin~

  3. #3
    Join Date
    Mar 2009
    Beans
    51

    Re: Need dialog --column-separator example

    Quote Originally Posted by conradin View Post
    --column-separator is only for radio or "check boxes" which, I believe is the same as the documented checklist boxes... so maybe that option isn't usable in the way youre attempting.
    heres a article i liked:
    http://www.linuxjournal.com/article/2807
    Yes, a good article. However, it doesn't show how to use the --column-separator option.

    --column-separator does work for menu as well, but as it turns out not in the way I thought. I was expecting to be able to do column breaks *between* menu items, like this:

    Code:
    ┌────────────── Menu! ─────────────────┐
    │ ┌──────────────────────────────────┐ │
    │ │1 Option One      5 Option Five   │ │
    │ │2 Option Two      6 Option Six    │ │
    │ │3 Option Three    7 Option Seven  │ │
    │ │4 Option Four     8 Option Eight  │ │
    │ └──────────────────────────────────┘ │
    ├──────────────────────────────────────┤
    │       <  OK  >    <Cancel>           │
    └──────────────────────────────────────┘
    however, it turns out column-separator is for creating columns *within* items, like this:

    Code:
    ┌────────────── Menu! ─────────────────┐
    │ ┌──────────────────────────────────┐ │
    │ │1 Option One    1-2 buckle my sho │ │
    │ │2 Option Two    Old MacDonald had │ │
    │ │3 Option Three  Jack and Jill wen │ │
    │ │4 Option Four   Old King Cole was │ │
    │ └──────────────────────────────────┘ │
    ├──────────────────────────────────────┤
    │       <  OK  >    <Cancel>           │
    └──────────────────────────────────────┘
    Code for the above looks like this:

    Code:
    #!/bin/bash
    
    dialog --title " Welcome to My Menu! " \
           --column-separator "|"          \
           --menu "" 6 0 0              \
                   "1" "Option One | 1-2 buckle my shoe"        \
                   "2" "Option Two | Old MacDonald had a farm"        \
                   "3" "Option Three | Jack and Jill went up a hill"      \
                   "4" "Option Four | Old King Cole was a merry old soul"       \
    2>temp
    Cancelled=$?
    Choice=`cat temp` ; rm temp
    if [ $Cancelled -eq 0 ] 
      then echo "You selected: $Choice"
      else echo "You cancelled!"
    fi
    Not what I was after, unfortunately. But I guess the question is solved.

    --Nathanael

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •