Jump to content

[bash] Zenity loop (raspbian)


Recommended Posts

Bonjour à tous ,

j'ai une petite interface utilisateur avec une liste de menu pour accéder à une sous liste . j'ai crée une boucle , lorsque que l'on appuie sur cancel on revient au menu principale .

Cela fonctionne bien pour le premier menu "go to menu" mais pas pour les autres je n'ai pas réussi à trouver pourquoi :/ .

voici mon code 

Code :
#!/bin/bash
 
 
while true; do
  choice="$(zenity --width=200 --height=150 --list --column "" --title="test" \
  "Go to next menu" \
 "test2" \
"test" \
"test3" \
"test4" 
 
 
  "Exit ")"
 
 
  case "${choice}" in
    "Go to next menu" )
      while true; do
        choice2="$(zenity --width=200 --height=150 --list --column "" --title="test" \
        "Do Something" \
        "Do Something Else " \
        "Back")"
 
 
        case "${choice2}" in
          "Do Something" )
            echo "hello"
          ;;
          "Do Something Else " )
            echo "hello"
          ;;
          *)
            break
          ;;
        esac
      done
    ;;
    *)
      break
    ;;
esac
done
case "${choice}" in
    "test2" )
      while true; do
        choice0="$(zenity --width=200 --height=150 --list --column "" --title="test" \
        "Do Something" \
        "Do Something Else " \
        "Back")"
 
 
        case "${choice0}" in
          "Do Something" )
            echo "hello"
          ;;
          "Do Something Else " )
            echo "hello"
          ;;
 
 
       *)
 
 
            break
 
          ;;
        esac
      done
    ;;
    *)
      break
    ;;
  esac
 
 
  case "${choice}" in
    "test" )
      while true; do
        choice3="$(zenity --width=200 --height=150 --list --column "" --title="test" \
        "Do Something" \
        "Do Something Else " \
        "Back")"
 
 
        case "${choice3}" in
          "Do Something" )
            echo "hello"
          ;;
          "Do Something Else " )
            echo "hello"
          ;;
          *)
            break
          ;;
        esac
      done
    ;;
    *)
      break
    ;;
  esac

 case "${choice}" in
    "test3" )
      while true; do
        choice4="$(zenity --width=200 --height=150 --list --column "" --title="test" \
        "Do Something" \
        "Do Something Else " \
        "Back")"
 
 
        case "${choice4}" in
          "Do Something" )
            echo "hello"
          ;;
          "Do Something Else " )
            echo "hello"
          ;;
          *)
            break
          ;;
        esac
      done
    ;;
    *)
      break
    ;;
esac
 
 
 case "${choice}" in
    "test4" )
      while true; do
        choice5="$(zenity --width=200 --height=150 --list --column "" --title="test" \
        "Do Something" \
        "Do Something Else " \
        "Back")"
 
 
        case "${choice5}" in
          "Do Something" )
            echo "hello"
          ;;
          "Do Something Else " )
            echo "hello"
          ;;
          *)
            break
          ;;
        esac
      done
    ;;
    *)
      break
    ;;
esac
done

j'ai aussi essayé cela mais je reste bloqué dans le menu test:

#!/bin/bash
 
while true; do
  choice="$(zenity --width=200 --height=150 --list --column "" --title="test" \
  "Go to next menu" \
 "test"
  "Exit ")"
 
  case "${choice}" in
    "Go to next menu" )
      while true; do
        choice2="$(zenity --width=200 --height=150 --list --column "" --title="test" \
        "Do Something" \
        "Do Something Else " \
        "Back")"
 
        case "${choice2}" in
          "Do Something" )
            echo "hello"
          ;;
          "Do Something Else " )
            echo "hello"
          ;;
          *)
            break
          ;;
        esac
      done
    ;;
    *)
      break
    ;;
esac
done
 
while true; do
  case "${choice}" in
    "test" )
 
      while true; do
        choice3="$(zenity --width=200 --height=150 --list --column "" --title="test" \
        "Do Something" \
        "Do Something Else " \
        "Back")"
 
        case "${choice3}" in
          "Do Something" )
            echo "hello"
          ;;
          "Do Something Else " )
            echo "hello"
          ;;
 
          *)
            break
          ;;
 
        esac
      done
 
    ;;
    *)
      break
    ;;
  esac
done

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...