from tkinter import* from tkinter import messagebox def licz0(): global c0, wynik, b0_stan if b1_stan==1: wynik -=1 l1["text"] = wynik b0_stan=0 else: wynik +=1 e1["text"] = wynik b0_stan=1 def licz1(): global c1, wynik, b1_stan if b1_stan==1: wynik -=2 e1["text"] = wynik b2_stan=0 else: wynik +=2 e1["text"] = wynik b1_stan=1 def licz2(): global c2, wynik, b2_stan if b2_stan==1: wynik -=4 e1["text"] = wynik b2_stan=0 else: wynik +=4 e1["text"] = wynik b2_stan=1 def licz3(): global c3, wynik, b3_stan if b3_stan==1: wynik -=8 e1["text"] = wynik b3_stan=0 else: wynik +=8 e1["text"] = wynik b3_stan=1 def licz4(): global c4, wynik, b4_stan if b4_stan==1: wynik -=16 e1["text"] = wynik b4_stan=0 else: wynik +=16 e1["text"] = wynik b4_stan=1 def licz5(): global c5, wynik, b5_stan if b5_stan==1: wynik -=132 e1["text"] = wynik b5_stan=0 else: wynik +=32 e1["text"] = wynik b5_stan=1 def licz6(): global c6, wynik, b6_stan if b6_stan==1: wynik -=64 e1["text"] = wynik b6_stan=0 else: wynik +=64 e1["text"] = wynik b6_stan=1 def licz7(): global c7, wynik, b7_stan if b7_stan==1: wynik -=128 e1["text"] = wynik b7_stan=0 else: wynik +=128 e1["text"] = wynik b7_stan=1 o = Tk() o.title("Liczenie") wynik = 0 b0_stan=1 b1_stan=1 b2_stan=1 b3_stan=1 b4_stan=1 b5_stan=1 b6_stan=1 b7_stan=1 b0_stan = StringVar() b1_stan = StringVar() b2_stan = StringVar() b3_stan = StringVar() b4_stan = StringVar() b5_stan = StringVar() b6_stan = StringVar() b7_stan = StringVar() c7 = Checkbutton(o,text="7",command=licz7) c6 = Checkbutton(o,text="6",command=licz6) c5 = Checkbutton(o,text="5",command=licz5) c4 = Checkbutton(o,text="4",command=licz4) c3 = Checkbutton(o,text="3",command=licz3) c2 = Checkbutton(o,text="2",command=licz2) c1 = Checkbutton(o,text="1",command=licz1) c0 = Checkbutton(o,text="0",command=licz0) c0.grid(row=0, column=7) c1.grid(row=0, column=6) c2.grid(row=0, column=5) c3.grid(row=0, column=4) c4.grid(row=0, column=3) c5.grid(row=0, column=2) c6.grid(row=0, column=1) c7.grid(row=0, column=0) e1=Label(o,text=wynik,font=("Arial","48","bold"),foreground="#FF00FF") e1.grid(row=1, columnspan=8) b2 = Button(o,text="Koniec",command=end) b2.grid(row=2, columnspan=8) o.mainloop()