Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to have a Zenity list-style menu show a code option like -r?

I am trying to make a simple GUI for an FFMPEG bash script. This is just one prompt for selecting a framerate for a video. I wanted one of the Zenity list columns to show the actual FFMPEG option that would be used, it would be for returning to be used in the FFMPEG code, but also to hopefully teach some FFMPEG syntax to the user. Like this:

#!/bin/sh

zenity --list \
    --title="Select framerate" \
    --column="ffmpeg code" --column="Framerate" --column="Description" \
    "-r 24000/1001" "23.976fps" "NTSC compatible 24fps" \
    "-r 30000/1001" "29.98fps" "NTSC compatible 30fps"

But this gives the Zenity error message:

This option is not available. Please see --help for all possible usages.

I think I understand what the problem is; Zenity thinks the -r is a Zenity option, and doesn't recognize it.

Just removing the - before the -r fixes it:

zenity --list \
    --title="Select framerate" \
    --column="ffmpeg code" --column="Framerate" --column="Description" \
    "r 24000/1001" "23.976fps" "NTSC compatible 24fps" \
    "r 30000/1001" "29.98fps" "NTSC compatible 30fps"

Shows no error and correctly displays:

A Zenity GUI with the aforementioned options, but no dash in front of the "r" as in "-r"

But then of course this would not teach anyone how to use the FFMPEG framerate option because the dash is needed.

Escaping the dash with a backslash like \- just prints the backslash too, which would also not teach anyone FFMPEG:

A Zenity GUI with the aforementioned options with "-r" in front of them.

I've also tried using ' and """ and ''' instead of the double quotes, but they give the same This option is not available... error message.

Is it just not possible to get Zenity to display something like that? I know there are ways around the problem if I just want the list to return the code ( just appending -r on beginning of the output) but as I said I'd like to be able to teach the user of the GUI a little about using the FFMPEG command line interface. Any ideas? Thank you.

Edit: By the way zenity --version on my system (Xubuntu 14.04) returns 3.8.0 if the version could be part of the problem.

share|improve this question
1  
Of course you can, here is a link to a script that does just that - bodhizazen.net/Tutorials/adblock – bodhi.zazen Feb 2 at 20:34
    
Looks like I asked a semi-duplicate question. Related post: unix.stackexchange.com/q/250171/154997 I just found this by accident after this was solved. – InverseTelecine Feb 4 at 19:18
up vote 4 down vote accepted

You can just put the space before the - character, like this:

zenity --list \
    --title="Select framerate" \
    --column="ffmpeg code" --column="Framerate" --column="Description" \
    " -r 24000/1001" "23.976fps" "NTSC compatible 24fps" \
    " -r 30000/1001" "29.98fps" "NTSC compatible 30fps"
share|improve this answer
    
Not sure where you got it, but it works :) – Jacob Vlijm Feb 2 at 20:47
    
Oh for the love of... it's pretty sad that I NEVER would have thought of that! Thank you so much incBrain! – InverseTelecine Feb 2 at 20:56

Write your data one line per cell into stdin, like

zenity --list \
  --title="Select framerate" \
  --column="ffmpeg code" --column="Framerate" --column="Description" <<EOF
-r 24000/1001
23.976fps
NTSC compatible 24fps
-r 30000/1001 
29.98fps 
NTSC compatible 30fps
EOF
share|improve this answer
    
Thank you for this Florian! incBrain's solution solved my problem, but I'm definitely saving your solution. It seems like a good worst-case-scenerio solution for other situations without such simple answers. – InverseTelecine Feb 2 at 20:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.