콤보 상자 사용법은 어디에 있습니까?


11

우연히 zenbo (버전 테스트 : 2.32.1)의 콤보 상자를 표시하는 것이 가능하다는 것을 알았습니다. 다음 코드를 참조하십시오.

#!/bin/bash
array=(a b c d e)
value=$(zenity --entry --title "Window title" --text "${array[@]}" --text "Insert your choice.")

결과는 다음 3 가지 이미지로 설명됩니다.

여기에 이미지 설명을 입력하십시오

여기에 이미지 설명을 입력하십시오

여기에 이미지 설명을 입력하십시오

그것에 대해 두 가지 질문이 있습니다.

  1. 이 기능에 대한 설명서가 있습니까? zenity documentation 에서 아무것도 찾지 못했습니다 .

  2. 내 배열의 첫 번째 값이 콤보 상자에 나타나지 않는 이유는 무엇입니까? 위의 예에서 내 배열은 (a b c d e)이며 콤보 상자에만을 표시합니다 b c d e.

    해결 방법으로 예를 들어 배열에 값을 추가합니다 (0 a b c d e).

답변:


5

배열의 첫 번째 요소는에 의해 사용됩니다 --text. 확장 후 zenitiy 라인은 다음과 같습니다.

zenity --entry --title "Window title" --text a b c d e --text "Insert your choice."
# Which zenity treats equivalent to
zenity --entry --title "Window title" --text a --text "Insert your choice." b c d e

먼저 텍스트를로 설정 a한 다음 "선택 항목 삽입"으로 대체하십시오. 나머지 주장은 선택이됩니다.

당신이 원하는 것은 :

zenity --entry --title "Window title" --text "Insert your choice." a b c d e
# Hence:
zenity --entry --title "Window title" --text "Insert your choice." "${array[@]}"

4

이것은 실제로 문서화되어 있습니다 (질문이 게시되지 않았을 때, 확인하지 않았을 수도 있음) zenity --help-forms .

$ LANG=en_US zenity --help-forms
Usage:
  zenity [OPTION...]

Forms dialog options
  --forms                                           Display forms dialog
  --add-entry=Field name                            Add a new Entry in forms dialog
  --add-password=Field name                         Add a new Password Entry in forms dialog
  --add-calendar=Calendar field name                Add a new Calendar in forms dialog
  --add-list=List field and header name             Add a new List in forms dialog
  --list-values=List of values separated by |       List of values for List
  --column-values=List of values separated by |     List of values for columns
  --add-combo=Combo box field name                  Add a new combo box in forms dialog
  --combo-values=List of values separated by |      List of values for combo box
  --show-header                                     Show the columns header
  --text=TEXT                                       Set the dialog text
  --separator=SEPARATOR                             Set output separator character
  --forms-date-format=PATTERN                       Set the format for the returned date

따라서:

zenity --forms --title "Window title" --text "Combo name" --add-combo "Insert your choice." --combo-values "a|b|c|d|e"

3

( reference )가 --text-entry아닌 값의 배열에 사용하고 싶다고 생각합니다 . 사용 :--text

#!/bin/bash
array=(a b c d e)
value=$(zenity --entry --title "Window title" --entry-text "${array[@]}" --text "Insert your choice.")

배열의 첫 번째 값으로 채워진 드롭 다운 상자의 기본값과 사용 가능한 모든 값이 표시됩니다.


답변 해주셔서 감사합니다. 매뉴얼이 콤보 상자를 참조하지 않는 것이 궁금합니다.
— jep
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.