Question

I am trying to implement a zenity radiolist that displays all the dir's returned from a find command. I am using a path that has 79 dir with which to test my commands. When I enter the command:

dir="/media/multiMediaA_intHdA720Gb/music/rockNextGen/lighter" ; artDir=$(find "$dir"  -maxdepth 1 -type d | sort | wc -l) ; echo "$artDir"

I get the expected output of 79 (dir's found). However, when I pipe this thru zenity like:

dir="/media/multiMediaA_intHdA720Gb/music/rockNextGen/lighter" ; artDir=$(find "$dir"  -maxdepth 1 -type d | sort | zenity --list --title "All albums : selected band" --text "Enter the band you want to listen to:" --column "Select" --column "Artist" --radiolist --height 900 --width 200) ; echo "$artDir"

I get a zenity radiolist window as expected, but only 39 of the 79 (~ half) of the dir's are listed.

I googled for possible zenity list size limits, but came up with nadda. Does anyone know if there is indeed such a limit with zenity, or what else I might be doing wrong, or perhaps an option omitted in the zenity call?

More details

Funny enough, if I pipe thru yad instead of zenity the result returned is 40 instead of 39, so still only ~ half of the dirs. If I select a different path containing,say 90 dirs, zenity lists only 44 of them, while yad lists 45.

Was it helpful?

Solution

I just tried seq 1 100 | zenity --list --column number on my box, and it showed all 100 numbers. My zenity version is 3.8.0.

So I'm guessing something else is going on in your script.

Update: I think I may have figured out what's going on. You've got two columns defined, so I think that means that zenity expects whatever args that follow (or input lines from stdin, in your case) to be in the form <column 1 value> <column 2 value> <column 1 value> <column 2 value> .... For instance if you have a column named "Name" and another column named "Age", you might do something like:

zenity --list --column Name --column Age Alice 25 Bob 40 Carol 37 ...

You've defined two columns but only provided values for one column.

Update 2: I just played around with it a bit on my box, and I think you just need to add some dummy values to populate column 1 with. Since the first column is just going to be a bunch of radio buttons, you don't really care about what values you're providing for that column. They can be all 1 or x or foo or whatever. When you select a radio button and hit OK, zenity is just going to pass back the value from column 2 anyway, so the values for column 1 are completely meaningless.

I just did this on my box and it worked as expected:

seq 1 100 | sed 's/^/x\n/g' | zenity --list --radiolist --column Select --column Number

That is, it showed 100 rows, with radio buttons in the first column, labeled "Select", and numbers 1-100 in the second column, labeled "Number".

Applying this idea to your command, you get:

dir="/media/multiMediaA_intHdA720Gb/music/rockNextGen/lighter" ; artDir=$(find "$dir"  -maxdepth 1 -type d | sort | sed 's/^/x\n/g' | zenity --list --title "All albums : selected band" --text "Enter the band you want to listen to:" --column "Select" --column "Artist" --radiolist --height 900 --width 200) ; echo "$artDir"

Try that and let us know if it worked.

OTHER TIPS

I used the following to select multiple files and removed the first two characters(period and forward slash) so that I could create a list of muliple files to be input as variable list $LIST.

dir=pwd

LIST=$(find . -maxdepth 1 -type d | sort | sed -r 's/^.{2}//g' | zenity --list --title "Select files" --column "Files" --multiple --separator=" " --height 900 --width 400) ; echo "$LIST"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top