Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
107 views
in Technique[技术] by (71.8m points)

python - how to make checkbox IntVar can do math?

hi i'm having problem on my python quick project to use checkbox as int, i can use intVar for them but IntVar cant be use to do math for my ifelse output

gejala = Label(window, text="Pilihlah gejala anda yang tertera dibawa ini : ")
gejala.grid(padx=10, pady=3)

pt_1 = IntVar()
pt_2 = IntVar()
pt_3 = IntVar()
pt_4 = IntVar()
pt_5 = IntVar()
pt_6 = int()

p1 = Checkbutton(window, text = "Sesak nafas", variable = pt_1, onvalue=30)
p1.grid(column=1)
p2 = Checkbutton(window, text = "Sulit bergerak atau berbicara", variable = pt_2, onvalue=20)
p2.grid(column=1)
p3 = Checkbutton(window, text = "Demam", variable = pt_3, onvalue=5)
p3.grid(column=1)
p4 = Checkbutton(window, text = "Batuk dan sakit tenggorokan", variable = pt_4, onvalue=6)
p4.grid(column=1)
p5 = Checkbutton(window, text = "Terasa hambar saat mengkonsumsi makanan dan minuman", variable = pt_5, onvalue=50)
p5.grid(column=1)
p6 = Checkbutton(window, text = "Terasa sakit atau tertekan pada bagian dada", variable = pt_6, onvalue=35)
p6.grid(column=1)



infeksi=pt_1+pt_2+pt_3+pt_4+pt_5+pt_6

def rumus():
    if infeksi >= 49:
        infek = Label(window, text="Anda terkena covid-19 , harap hubungi puskesmas atau rumah sakit terdekat dan lakukan isolasi mandiri.")
        infek.grid(column=1)
    else:
        infek = Label(window, text="Anda bebas dari covid-19, harap selalu mematuhi protokol yang ada.")
        infek.grid(column=1)


diag = Button(window, text="Diagnosa", command=rumus)
diag.grid(column=1, pady=5)
question from:https://stackoverflow.com/questions/65952276/how-to-make-checkbox-intvar-can-do-math

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...