zenity list and for loop

蹲街弑〆低调 提交于 2019-12-11 08:53:52

问题


for i in $(seq 1 10); do

echo 'bla bla'

echo 'xxx'

echo $i

done | select=$(zenity --list --title="title" --text="text" --column="X" --column="Y" --column="Z");

I try to create a checklist with zenity, my problem is that $select is always empty. I try to do it in few other ways, like this one:

for i in $(seq 1 10)
do
    x="bla bla"
    y="xxx"
    z="$i"
    table="$table '$x' '$y' '$z'"
done
eval zenity --list --title="title" --text="text" --column="X" --column="Y" --column="Z" $table

In this way the $select variable isn't empty but if there are spaces in some variable (like $x for example) zenity split it to 2 (or more) columns.

I need other solution or any fix for my code(s)?

Thanks!


回答1:


You can try this other approach:

#!/bin/bash

for i in $(seq 1 10)
do
    echo "bla bla"
    echo "xxx"
    echo "$i"
done | zenity --list --title="title" --text="text" --column="X" --column="Y" --column="Z"

Each line populate the table from the first column to the last, and then again on a new row, until the input stream ends.



来源:https://stackoverflow.com/questions/4706029/zenity-list-and-for-loop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!