Widget: colore

Il menu seleziona il colore della freccia

Web VPython 3.2
#----------------------------------------------------------- parametri
COLORI = {"arancio": color.orange,
          "azzurro": color.cyan,
          "bianco" : color.white,
          "blu"    : color.blue,
          "giallo" : color.yellow,
          "rosso"  : color.red,
          "verde"  : color.green}
#----------------------------------------------------------- scena
freccia = arrow(color = color.white)
#----------------------------------------------------------- binding
def bind_menu_colori(evt):
    colore        = evt.selected
    freccia.color = COLORI[colore]
#----------------------------------------------------------- i/o
scene.append_to_caption("\nColore: ")
menu_colori = menu(bind    = bind_menu_colori,
                   choices = list(COLORI.keys()),
                   index   = 2)

Lascia un commento