bash - bash - 对话框命令 - “全选”按钮
问题描述
下面的链接:
https
://serverfault.com/questions/144939
它正确显示了如何使用“对话框”命令创建菜单,但没有显示如何创建“全选”快捷按钮。
如何创建“全选”按钮?
解决方案
像这样:
#!/bin/bash
onoff=off # all unset by defaul
dialog1(){ dialog --output-fd 1 --extra-button --extra-label "Select All" --checklist "Select options:" 0 0 0 "$@"; }
dialog2(){ choices=$(dialog1 "${options[@]}"); }
set_options(){ # make options array dynamic
options=(
1 "Option 1" $onoff
2 "Option 2" $onoff
3 "Option 3" $onoff
4 "Option 4" $onoff
)
}
set_option
dialog2
case $? in # if 'Select All' presssed
3) onoff=on # set all to on
set_options # reassemble options
dialog2;; # and run dialog again
esac
clear
echo $choices
推荐阅读
- python - PyTorch DataLoader 如何与 PyTorch 数据集交互以转换批次?
- javascript - 如何关闭 echarts 的自动放大功能?
- python - requests.exceptions.HTTPError:429 客户端错误:对 url 的请求过多
- javascript - 如何检查所有输入值是否等于我的数据?
- c++ - 带有犰狳库的复矩阵指数
- java - ./gradlew contractTest 命令在添加 JPA 依赖项后失败
- python - 如何使用 PDFMiner 在 Python 中提取 PDF 中文本的字体颜色?
- enterprise-architect - 无法将构造型添加到工具箱页面
- graphql - 用于过滤数据库文档的 GraphQL 查询
- python - 停止 Pika (RabbitMQ) 中 SelectConnection 的 ioloop 阻塞