import tkinter as tk
window = tk.Tk()
window.title("daxiangcai's title")
window.geometry('800x400')
def printselection():
if var1.get() and var2.get():
l.config(text='I love both')
if not var1.get() and not var2.get():
l.config(text="I don't love either")
if var1.get() and not var2.get():
l.config(text='I love Python')
if not var1.get() and var2.get():
l.config(text='I love Java')
var1 = tk.IntVar()
var2 = tk.IntVar()
l = tk.Label(window, bg='green', width=20, text='empty')
l.pack()
c1 = tk.Checkbutton(window, text='Python', variable=var1, onvalue=1, offvalue=0, command=printselection) # 代表选中时var1的值设置为1,未选中时设置成0
c1.pack()
c2 = tk.Checkbutton(window, text='Java', variable=var2, onvalue=1, offvalue=0, command=printselection)
c2.pack()
window.mainloop()