zenity列表和for循环 [英] zenity list and for loop

查看:333
本文介绍了zenity列表和for循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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");

我尝试创建一个带有zenity的清单,我的问题是$ select始终为空. 我尝试通过其他几种方式来做到这一点,例如:

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

这样,$ select变量就不会为空,但是如果某个变量中有空格(例如$ x),则zenity会将其分为2(或更多)列.

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)?

谢谢!

推荐答案

您可以尝试以下另一种方法:

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.

这篇关于zenity列表和for循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆