Converting a radio list from zenity to yad

905 views
Skip to first unread message

Joe Consultant

unread,
Feb 8, 2013, 5:45:26 PM2/8/13
to yad-c...@googlegroups.com
I'm in the process of converting all my scripts from zenity to yad.  I just converted one that uses a radio list.

Both commands below work.

To do so I had to add a couple of options to the yad command.  Having to specify a null separator doesn't look right, but if I didn't, I got my string followed by a vbar (|) which caused the rest of the script to fail.  If I didn't specify --print-column=2, I got "TRUE|string|" which was even worse.

  ##NEWPR=$(zenity  --list  --title "Configure Default Printer" --text "New Default Printer" --width=300 --radiolist  --column "Pick" --column "Printer" ${CHOICES})

  NEWPR=$(yad  --list  --title "Configure Default Printer" --text "New Default Printer" --width=300 --radiolist  --column "Pick" --column "Printer" --print-column=2 --separator="" ${CHOICES})

Since I am using a radio list, it "should" return only one value, so why would a separator be there at all?

Why would it ever return the "TRUE"? (Why would anyone want that?)

Am I doing something wrong?

On a related note, when specifying a dialog title in zenity, I believe the dialog box was always automatically wide enough to display it, but with yad, I have to manually figure out a sufficient width= option to keep it from being truncated.  Is there a way around this?

TIA
    Joe

Julio C. Neves

unread,
Feb 8, 2013, 8:19:51 PM2/8/13
to yad-c...@googlegroups.com
Comparing both softwares, you can see that yad is much more complex and  talking about ages, yad is just a little kid near the ancient zenity.

I believe that yad in the next future will be perfect and much, much better than zenity. Tks Victor.

But there are some tricks that you can use. For example, to avoid the manipulation of vbars (|):

Supose that a variable var that received the output of a --form, is equal to field 1|field 2|field 3|field 4|
$ IFS=\| read -a arr <<< "$var"
$ echo ${arr[1]}
field 2
$ echo ${arr[3]}
field 4
$ echo ${arr[@]}
field 1 field 2 field 3 field 4

Or, if you don't like to use array, you simply:
$ IFS=\| read f1 f2 f3 f4 <<< "$var"
$ printf '%10s%10s%10s%10s\n' "$f1" "$f2" "$f3" "$f4"
   field 1   field 2   field 3   field 4

Abcs,
Julio
A partir de  01/04  lecionarei um
curso completo de Shell em Recife
Clique aqui  para mais  detalhes.
@juliobash




2013/2/8 Joe Consultant <joseph...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "yad-common" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yad-common+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Victor Ananjevsky

unread,
Feb 12, 2013, 12:12:22 AM2/12/13
to yad-c...@googlegroups.com
On Fri, 8 Feb 2013 17:45:26 -0500
Joe Consultant <joseph...@gmail.com> wrote:

> I'm in the process of converting all my scripts from zenity to yad. I just
> converted one that uses a radio list.
>
> Both commands below work.
>
> To do so I had to add a couple of options to the yad command. Having to
> specify a null separator doesn't look right, but if I didn't, I got my
> string followed by a vbar (|) which caused the rest of the script to fail.
> If I didn't specify --print-column=2, I got "TRUE|string|" which was even
> worse.
>
> ##NEWPR=$(zenity --list --title "Configure Default Printer" --text "New
> Default Printer" --width=300 --radiolist --column "Pick" --column
> "Printer" ${CHOICES})
>
> NEWPR=$(yad --list --title "Configure Default Printer" --text "New
> Default Printer" --width=300 --radiolist --column "Pick" --column
> "Printer" --print-column=2 --separator="" ${CHOICES})
>
> Since I am using a radio list, it "should" return only one value, so why
> would a separator be there at all?

what version of yad and gtk+ you use?

>
> Why would it ever return the "TRUE"? (Why would anyone want that?)
>
> Am I doing something wrong?
>
> On a related note, when specifying a dialog title in zenity, I believe the
> dialog box was always automatically wide enough to display it, but with
> yad, I have to manually figure out a sufficient width= option to keep it
> from being truncated. Is there a way around this?
>

do you mean --title option, when saying "dialog title"? if so, you are wrong. this option
sets the window title and MUST be handled only by window manager

> TIA
> Joe
>
> --
> You received this message because you are subscribed to the Google Groups "yad-common" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to yad-common+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>


--
Victor Ananjevsky <anan...@gmail.com>
Reply all
Reply to author
Forward
0 new messages