Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [Python] Come faccio a capire il valore di un Radiobutton?

    codice:
    from Tkinter import *
    
    master = Tk()
    
    def asd():
        print XXX
    
    text = Text(master, width=50, height=10)
    text.insert(INSERT, "click here!", "a")
    text.pack()
    
    v = IntVar()
    Radiobutton(master, text="One", variable=v, value=1).pack(anchor=W)
    Radiobutton(master, text="Two", variable=v, value=2).pack(anchor=W)
    Radiobutton(master, text="Three", variable=v, value=3).pack(anchor=W)
    Radiobutton(master, text="Four", variable=v, value=4).pack(anchor=W)
    Radiobutton(master, text="Five", variable=v, value=5).pack(anchor=W)
    Radiobutton(master, text="Six", variable=v, value=6).pack(anchor=W)
    
    
    B = Button(master, text='Click!', command=asd)
    B.pack()
    
    
    mainloop()
    Cosa devo scrivere al posto di XXX (6' riga) per fare in modo che mi stampi a video One o 1 se è selezionato la 1' opzione, Two o 2 se è selezionata la 2' e così via?

  2. #2
    Risolto, dovevo usare v.get().

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.