1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
# coding:utf-8
import tkinter as tk
from tkinter import *
def ut_dt(*args):
if test.get() == 1:
a = "blue"
print(a)
else:
a="red"
print(a)
# comment faire pour utiliser a hors de la fonction de sorte à la transformer en a.get() .......
mainapp = tk.Tk()
test = tk.IntVar()
test.trace("w", ut_dt)
boutton_1 = tk.Radiobutton(mainapp, text="blue", value=1, variable=test)
boutton_2 = tk.Radiobutton(mainapp, text="red", value=0, variable=test)
boutton_1.pack()
boutton_2.pack()
mainapp.mainloop() |
Partager