def __init__(self, risk_factor, res): HeartAtt_root = Tk() HeartAtt_root.title("Diagnosing Heart Attack") cent = "1000x680+160+40" HeartAtt_root.geometry(cent) #HeartAtt_root.geometry("1400x750") HeartAtt_r_1 = StringVar() HeartAtt_r_2 = StringVar() HeartAtt_r_3 = StringVar() HeartAtt_r_4 = StringVar() HeartAtt_r_5 = StringVar() HeartAtt_r_6 = StringVar() # Setting up Canvas: HeartAtt_my_canvas = Canvas(HeartAtt_root) HeartAtt_my_canvas.pack(side=LEFT, fill=BOTH, expand=1) # Background: HeartAtt_img = Image.open("background.png") HeartAtt_img = HeartAtt_img.resize((1500, 1280), Image.ANTIALIAS) HeartAtt_bg = ImageTk.PhotoImage(HeartAtt_img) HeartAtt_my_canvas.create_image(0, 0, image=HeartAtt_bg, anchor="nw") # Creating title text: HeartAtt_my_canvas.create_text(520, 40, text="Answer some question", font=("Times", 20), fill="white") # quetion 1: HeartAtt_my_canvas.create_text(195, 100, text="1) Do you have Chest Pain ?", font=("helvetica", 15), fill="black") HeartAtt_but_1 = Radiobutton(HeartAtt_my_canvas, text="yes", variable=HeartAtt_r_1, value="yes", fill="white", radius=8) HeartAtt_but_1.put(120, 150) HeartAtt_but_2 = Radiobutton(HeartAtt_my_canvas, text="no", variable=HeartAtt_r_1, value="no", fill="white", radius=8) HeartAtt_but_2.put(220, 150) #HeartAtt_r_1.set("yes") # question 2: HeartAtt_my_canvas.create_text( 245, 200, text="2) Do you have shortness of breath ?", font=("helvetica", 15), fill="black") HeartAtt_but_3 = Radiobutton(HeartAtt_my_canvas, text="yes", variable=HeartAtt_r_2, value="yes", fill="white", radius=8) HeartAtt_but_3.put(120, 250) HeartAtt_but_4 = Radiobutton(HeartAtt_my_canvas, text="no", variable=HeartAtt_r_2, value="no", fill="white", radius=8) HeartAtt_but_4.put(220, 250) #HeartAtt_r_2.set("yes") # question 3: HeartAtt_my_canvas.create_text( 310, 300, text="3) Do you feel pain discomfort in neck / lower jaw ?", font=("helvetica", 15), fill="black") HeartAtt_but_5 = Radiobutton(HeartAtt_my_canvas, text="yes", variable=HeartAtt_r_3, value="yes", fill="white", radius=8) HeartAtt_but_5.put(120, 350) HeartAtt_but_6 = Radiobutton(HeartAtt_my_canvas, text="no", variable=HeartAtt_r_3, value="no", fill="white", radius=8) HeartAtt_but_6.put(220, 350) #HeartAtt_r_3.set("yes") # question 4: HeartAtt_my_canvas.create_text( 240, 400, text="4) Are sweating more than usual ?", font=("helvetica", 15), fill="black") HeartAtt_but_7 = Radiobutton(HeartAtt_my_canvas, text="yes", variable=HeartAtt_r_4, value="yes", fill="white", radius=8) HeartAtt_but_7.put(120, 450) HeartAtt_but_8 = Radiobutton(HeartAtt_my_canvas, text="no", variable=HeartAtt_r_4, value="no", fill="white", radius=8) HeartAtt_but_8.put(220, 450) #HeartAtt_r_4.set("yes") # question 5: HeartAtt_my_canvas.create_text(210, 500, text="5) Do you sense palpitation ?", font=("helvetica", 15), fill="black") HeartAtt_but_9 = Radiobutton(HeartAtt_my_canvas, text="yes", variable=HeartAtt_r_5, value="yes", fill="white", radius=8) HeartAtt_but_9.put(120, 550) HeartAtt_but_10 = Radiobutton(HeartAtt_my_canvas, text="no", variable=HeartAtt_r_5, value="no", fill="white", radius=8) HeartAtt_but_10.put(220, 550) #HeartAtt_r_5.set("male") # question 6: HeartAtt_my_canvas.create_text(180, 600, text="6)Do you feel nausea ?", font=("helvetica", 15), fill="black") HeartAtt_but_11 = Radiobutton(HeartAtt_my_canvas, text="yes", variable=HeartAtt_r_6, value="yes", fill="white", radius=8) HeartAtt_but_11.put(120, 650) HeartAtt_but_12 = Radiobutton(HeartAtt_my_canvas, text="no", variable=HeartAtt_r_6, value="no", fill="white", radius=8) HeartAtt_but_12.put(220, 650) #HeartAtt_r_6.set("yes") HeartAtt_obj = ph.Prog() def calculate_fatality_risk(): global fatality_r HeartAtt_que_1 = HeartAtt_r_1.get() HeartAtt_que_2 = HeartAtt_r_2.get() HeartAtt_que_3 = HeartAtt_r_3.get() HeartAtt_que_4 = HeartAtt_r_4.get() HeartAtt_que_5 = HeartAtt_r_5.get() HeartAtt_que_6 = HeartAtt_r_6.get() print(HeartAtt_que_1) print(HeartAtt_que_2) print(HeartAtt_que_3) print(HeartAtt_que_4) print(HeartAtt_que_5) fatality_r = HeartAtt_obj.diagnose_heart_attack( HeartAtt_que_1, HeartAtt_que_2, HeartAtt_que_3, HeartAtt_que_4, HeartAtt_que_5, HeartAtt_que_6, risk_factor) print("Returned value is : " + str(fatality_r)) print("Your fatality risk is : " + str(fatality_r) + "%") message_HeartAtt_res = messagebox.showinfo( "Risk factor ", "Your fatality risk is : " + str(fatality_r) + "%") if message_HeartAtt_res == 'ok': if fatality_r > 0: HeartAtt_root.destroy() Result.GUI_result("Heart Attack", fatality_r, risk_factor, res) else: HeartAtt_root.destroy() stroke.GUI_Stroke(risk_factor, res) #Result.GUI_result("Unkown", fatality_r, risk_factor) print("Back here in GUI_CHD") HeartAtt_but = ttk.Button(HeartAtt_my_canvas, text="submit", width=18, command=calculate_fatality_risk) HeartAtt_my_canvas.create_window(850, 650, window=HeartAtt_but) #obj.calculate_risk_factor(que_1,que_2, que_3, que_4, que_5, que_6, que_7, que_8, que_9, que_10) HeartAtt_root.mainloop()
def __init__(self, res): root = Tk() root.title("Risk Analysis") root.geometry("1200x750") r_1 = StringVar() r_2 = StringVar() r_3 = StringVar() r_4 = StringVar() r_5 = StringVar() r_6 = StringVar() r_7 = StringVar() r_8 = StringVar() r_9 = StringVar() r_10 = StringVar() # Setting up Canvas: my_canvas = Canvas(root) my_canvas.pack(side=LEFT, fill=BOTH, expand=1) # Background: img = Image.open("background.png") img = img.resize((1500, 1280), Image.ANTIALIAS) bg = ImageTk.PhotoImage(img) my_canvas.create_image(0, 0, image=bg, anchor="nw") # Creating title text: my_canvas.create_text(650, 40, text="Answer some question", font=("Times", 20), fill="white") # quetion 1: my_canvas.create_text(140, 100, text="1) Do you smoke?", font=("helvetica", 15), fill="black") but_1 = Radiobutton(my_canvas, text="yes", variable=r_1, value="yes", fill="white", radius=8) but_1.put(90, 150) but_2 = Radiobutton(my_canvas, text="no", variable=r_1, value="no", fill="white", radius=8) but_2.put(180, 150) # r_1.set("yes") # question 2: my_canvas.create_text( 260, 200, text="2) How often you have junk/unhealthy food ?", font=("helvetica", 15), fill="black") but_3 = Radiobutton(my_canvas, text="often", variable=r_2, value="often", fill="white", radius=8) but_3.put(90, 250) but_4 = Radiobutton(my_canvas, text="rarely", variable=r_2, value="rarely", fill="white", radius=8) but_4.put(180, 250) # r_2.set("often") # question 3: my_canvas.create_text( 260, 300, text="3) How often you do some physical activity ?", font=("helvetica", 15), fill="black") but_5 = Radiobutton(my_canvas, text="often", variable=r_3, value="often", fill="white", radius=8) but_5.put(90, 350) but_6 = Radiobutton(my_canvas, text="rarely", variable=r_3, value="rarely", fill="white", radius=8) but_6.put(180, 350) # r_3.set("often") # question 4: my_canvas.create_text( 250, 400, text="4) How often you feel stressed in daily life ?", font=("helvetica", 15), fill="black") but_7 = Radiobutton(my_canvas, text="often", variable=r_4, value="often", fill="white", radius=8) but_7.put(90, 450) but_8 = Radiobutton(my_canvas, text="rarely", variable=r_4, value="rarely", fill="white", radius=8) but_8.put(180, 450) # r_4.set("often") # question 5: my_canvas.create_text(170, 500, text="5) What is your gender ?", font=("helvetica", 15), fill="black") but_9 = Radiobutton(my_canvas, text="male", variable=r_5, value="male", fill="white", radius=8) but_9.put(90, 550) but_10 = Radiobutton(my_canvas, text="female", variable=r_5, value="female", fill="white", radius=8) but_10.put(180, 550) # r_5.set("male") # question 6: my_canvas.create_text( 280, 600, text="6) Do you have genetic history of heart disease ?", font=("helvetica", 15), fill="black") but_11 = Radiobutton(my_canvas, text="yes", variable=r_6, value="yes", fill="white", radius=8) but_11.put(90, 650) but_12 = Radiobutton(my_canvas, text="no", variable=r_6, value="no", fill="white", radius=8) but_12.put(180, 650) # r_6.set("yes") # question 7: my_canvas.create_text(900, 100, text="7) Do you have diabetes ?", font=("helvetica", 15), fill="black") but_13 = Radiobutton(my_canvas, text="yes", variable=r_7, value="yes", fill="white", radius=8) but_13.put(820, 150) but_14 = Radiobutton(my_canvas, text="no", variable=r_7, value="no", fill="white", radius=8) but_14.put(920, 150) # r_7.set("yes") # question 8: my_canvas.create_text(960, 200, text="8) What is your total cholesterol count ?", font=("helvetica", 15), fill="black") but_15 = Radiobutton(my_canvas, text=">200", variable=r_8, value=">200", fill="white", radius=8) but_15.put(820, 250) but_16 = Radiobutton(my_canvas, text="<200", variable=r_8, value="<200", fill="white", radius=8) but_16.put(920, 250) # r_8.set(">200") # question 9: my_canvas.create_text(950, 300, text="9) Have you had heart attack before ?", font=("helvetica", 15), fill="black") but_17 = Radiobutton(my_canvas, text="yes", variable=r_9, value="yes", fill="white", radius=8) but_17.put(820, 350) but_18 = Radiobutton(my_canvas, text="no", variable=r_9, value="no", fill="white", radius=8) but_18.put(920, 350) # r_9.set("yes") # question 10: my_canvas.create_text(910, 400, text="10) What is your BMI index ?", font=("helvetica", 15), fill="black") but_19 = Radiobutton(my_canvas, text=">40", variable=r_10, value=">40", fill="white", radius=8) but_19.put(820, 450) but_20 = Radiobutton(my_canvas, text="<40", variable=r_10, value="<40", fill="white", radius=8) but_20.put(920, 450) # r_10.set(">40") # creating object of prog obj = ph.Prog() def calculate_risk(): #Taking response form radio button global risk_factor que_1 = r_1.get() que_2 = r_2.get() que_3 = r_3.get() que_4 = r_4.get() que_5 = r_5.get() que_6 = r_6.get() que_7 = r_7.get() que_8 = r_8.get() que_9 = r_9.get() que_10 = r_10.get() print(que_1) print(que_2) print(que_3) print(que_4) print(que_5) print(que_6) print(que_7) print(que_8) print(que_9) print(que_10) tup = obj.calculate_risk_factor(que_1, que_2, que_3, que_4, que_5, que_6, que_7, que_8, que_9, que_10) risk = tup[0] total_no_questions = tup[1] print("Returned value is : " + str(risk)) risk_factor = risk * (100 / total_no_questions) print("Your risk of having heart related issue is : " + str(risk_factor) + "%") messagboxRes = messagebox.showinfo( "Risk factor ", "Your risk of having heart related issue is : " + str(risk_factor) + "%") if messagboxRes == 'ok': root.destroy() print(risk_factor) Gui_arr.GUI_arrythmias(risk_factor, res) print("Back Here") # creating submit button but = ttk.Button(my_canvas, text="submit", width=18, command=calculate_risk) my_canvas.create_window(870, 550, window=but) root.mainloop()
def __init__(self, risk_factor, res): root_CAD = Tk() root_CAD.title("Diagnosing CAD") cent = "1000x660+160+40" root_CAD.geometry(cent) print("Here") CAD_r_1 = StringVar() CAD_r_2 = StringVar() CAD_r_3 = StringVar() CAD_r_4 = StringVar() CAD_r_5 = StringVar() CAD_r_6 = StringVar() CAD_r_7 = StringVar() CAD_my_canvas = Canvas(root_CAD) CAD_my_canvas.pack(side=LEFT, fill=BOTH, expand=1) # Background: CAD_img = Image.open("background.png") CAD_img = CAD_img.resize((1800, 1280), Image.ANTIALIAS) CAD_bg = ImageTk.PhotoImage(CAD_img) CAD_my_canvas.create_image(0, 0, image=CAD_bg, anchor="nw") # Creating title text: CAD_my_canvas.create_text(520, 40, text="Answer some question", font=("Times", 20), fill="white") # quetion 1: CAD_my_canvas.create_text(220, 100, text="1) Do you have chest pain/angina ?", font=("helvetica", 15), fill="black") CAD_but_1 = Radiobutton(CAD_my_canvas, text="yes", variable=CAD_r_1, value="yes", fill="white", radius=8) CAD_but_1.put(120, 150) CAD_but_2 = Radiobutton(CAD_my_canvas, text="no", variable=CAD_r_1, value="no", fill="white", radius=8) CAD_but_2.put(220, 150) # CAD_r_1.set("yes") # question 2: CAD_my_canvas.create_text(230, 200, text="2) Do you have pain in legs or arms ?", font=("helvetica", 15), fill="black") CAD_but_3 = Radiobutton(CAD_my_canvas, text="yes", variable=CAD_r_2, value="yes", fill="white", radius=8) CAD_but_3.put(120, 250) CAD_but_4 = Radiobutton(CAD_my_canvas, text="no", variable=CAD_r_2, value="no", fill="white", radius=8) CAD_but_4.put(220, 250) # CAD_r_2.set("yes") # question 3: CAD_my_canvas.create_text( 260, 300, text="3) Have you experienced mental confusion ?", font=("helvetica", 15), fill="black") CAD_but_5 = Radiobutton(CAD_my_canvas, text="yes", variable=CAD_r_3, value="yes", fill="white", radius=8) CAD_but_5.put(120, 350) CAD_but_6 = Radiobutton(CAD_my_canvas, text="no", variable=CAD_r_3, value="no", fill="white", radius=8) CAD_but_6.put(220, 350) # CAD_r_3.set("yes") # question 4: CAD_my_canvas.create_text(170, 400, text="4) Do you feel fatigue ?", font=("helvetica", 15), fill="black") CAD_but_7 = Radiobutton(CAD_my_canvas, text="yes", variable=CAD_r_4, value="yes", fill="white", radius=8) CAD_but_7.put(120, 450) CAD_but_8 = Radiobutton(CAD_my_canvas, text="no", variable=CAD_r_4, value="no", fill="white", radius=8) CAD_but_8.put(220, 450) # CAD_r_4.set("yes") # question 5: CAD_my_canvas.create_text(230, 500, text="5) Do you feel shortness of breath ?", font=("helvetica", 15), fill="black") CAD_but_9 = Radiobutton(CAD_my_canvas, text="yes", variable=CAD_r_5, value="yes", fill="white", radius=8) CAD_but_9.put(120, 550) CAD_but_10 = Radiobutton(CAD_my_canvas, text="no", variable=CAD_r_5, value="no", fill="white", radius=8) CAD_but_10.put(220, 550) # CAD_r_5.set("yes") CAD_obj = ph.Prog() def calculate_fatality_risk(): global fatality_r CAD_que_1 = CAD_r_1.get() CAD_que_2 = CAD_r_2.get() CAD_que_3 = CAD_r_3.get() CAD_que_4 = CAD_r_4.get() CAD_que_5 = CAD_r_5.get() print(CAD_que_1) print(CAD_que_2) print(CAD_que_3) print(CAD_que_4) print(CAD_que_5) fatality_r = CAD_obj.diagnose_coronary_artery_disease( CAD_que_1, CAD_que_2, CAD_que_3, CAD_que_4, CAD_que_5, risk_factor) print("Returned value is : " + str(fatality_r)) print("Your fatality risk is : " + str(fatality_r) + "%") message_CAD_res = messagebox.showinfo( "Risk factor ", "Your fatality risk is : " + str(fatality_r) + "%") if message_CAD_res == 'ok': if fatality_r > 0: root_CAD.destroy() Result.GUI_result("Coronary Artery Disease", fatality_r, risk_factor, res) else: root_CAD.destroy() HeartAtt.GUI_Heart_Attack(risk_factor, res) #Result.GUI_result("Unkown", fatality_r, risk_factor) print("Back here in GUI_CHD") but_To_result = ttk.Button(CAD_my_canvas, text="submit", width=18, command=calculate_fatality_risk) CAD_my_canvas.create_window(770, 580, window=but_To_result) root_CAD.mainloop()
def __init__(self, risk_factor, res): root_Stroke = Tk() root_Stroke.title("Diagnosing stroke") cent = "1000x660+160+40" root_Stroke.geometry(cent) print("Here") Stroke_r_1 = StringVar() Stroke_r_2 = StringVar() Stroke_r_3 = StringVar() Stroke_r_4 = StringVar() Stroke_r_5 = StringVar() Stroke_r_6 = StringVar() Stroke_r_7 = StringVar() Stroke_my_canvas = Canvas(root_Stroke) Stroke_my_canvas.pack(side=LEFT, fill=BOTH, expand=1) # Background: Stroke_img = Image.open("background.png") Stroke_img = Stroke_img.resize((1800, 1280), Image.ANTIALIAS) Stroke_bg = ImageTk.PhotoImage(Stroke_img) Stroke_my_canvas.create_image(0, 0, image=Stroke_bg, anchor="nw") # Creating title text: Stroke_my_canvas.create_text(520, 40, text="Answer some question", font=("Times", 20), fill="white") # quetion 1: Stroke_my_canvas.create_text( 310, 100, text="1) Do you have difficulty in walking due to weak muscels ?", font=("helvetica", 15), fill="black") Stroke_but_1 = Radiobutton(Stroke_my_canvas, text="yes", variable=Stroke_r_1, value="yes", fill="white", radius=8) Stroke_but_1.put(120, 150) Stroke_but_2 = Radiobutton(Stroke_my_canvas, text="no", variable=Stroke_r_1, value="no", fill="white", radius=8) Stroke_but_2.put(220, 150) # Stroke_r_1.set("yes") # question 2: Stroke_my_canvas.create_text( 230, 200, text="2) Do you thin your vision is blummed ?", font=("helvetica", 15), fill="black") Stroke_but_3 = Radiobutton(Stroke_my_canvas, text="yes", variable=Stroke_r_2, value="yes", fill="white", radius=8) Stroke_but_3.put(120, 250) Stroke_but_4 = Radiobutton(Stroke_my_canvas, text="no", variable=Stroke_r_2, value="no", fill="white", radius=8) Stroke_but_4.put(220, 250) # Stroke_r_2.set("yes") # question 3: Stroke_my_canvas.create_text( 240, 300, text="3) Have you experienced loss of speech ?", font=("helvetica", 15), fill="black") Stroke_but_5 = Radiobutton(Stroke_my_canvas, text="yes", variable=Stroke_r_3, value="yes", fill="white", radius=8) Stroke_but_5.put(120, 350) Stroke_but_6 = Radiobutton(Stroke_my_canvas, text="no", variable=Stroke_r_3, value="no", fill="white", radius=8) Stroke_but_6.put(220, 350) # Stroke_r_3.set("yes") # question 4: Stroke_my_canvas.create_text( 205, 400, text="4) Do you feel fatigue or vertigo ?", font=("helvetica", 15), fill="black") Stroke_but_7 = Radiobutton(Stroke_my_canvas, text="yes", variable=Stroke_r_4, value="yes", fill="white", radius=8) Stroke_but_7.put(120, 450) Stroke_but_8 = Radiobutton(Stroke_my_canvas, text="no", variable=Stroke_r_4, value="no", fill="white", radius=8) Stroke_but_8.put(220, 450) # Stroke_r_4.set("yes") # question 5: Stroke_my_canvas.create_text( 235, 500, text="5) Is your cognetive power decreased ?", font=("helvetica", 15), fill="black") Stroke_but_9 = Radiobutton(Stroke_my_canvas, text="yes", variable=Stroke_r_5, value="yes", fill="white", radius=8) Stroke_but_9.put(120, 550) Stroke_but_10 = Radiobutton(Stroke_my_canvas, text="no", variable=Stroke_r_5, value="no", fill="white", radius=8) Stroke_but_10.put(220, 550) # Stroke_r_5.set("yes") Stroke_obj = ph.Prog() def calculate_fatality_risk(): global fatality_r Stroke_que_1 = Stroke_r_1.get() Stroke_que_2 = Stroke_r_2.get() Stroke_que_3 = Stroke_r_3.get() Stroke_que_4 = Stroke_r_4.get() Stroke_que_5 = Stroke_r_5.get() print(Stroke_que_1) print(Stroke_que_2) print(Stroke_que_3) print(Stroke_que_4) print(Stroke_que_5) fatality_r = Stroke_obj.diagnose_stroke(Stroke_que_1, Stroke_que_2, Stroke_que_3, Stroke_que_4, Stroke_que_5, risk_factor) print("Returned value is : " + str(fatality_r)) print("Your fatality risk is : " + str(fatality_r) + "%") message_Stroke_res = messagebox.showinfo( "Risk factor ", "Your fatality risk is : " + str(fatality_r) + "%") if message_Stroke_res == 'ok': if fatality_r > 0: root_Stroke.destroy() Result.GUI_result("Stroke", fatality_r, risk_factor, res) else: root_Stroke.destroy() Result.GUI_result("Unkown Disease", fatality_r, risk_factor, res) #Result.GUI_result("Unkown", fatality_r, risk_factor) print("Back here in GUI_CHD") Stroke_but = ttk.Button(Stroke_my_canvas, text="submit", width=18, command=calculate_fatality_risk) Stroke_my_canvas.create_window(800, 580, window=Stroke_but) root_Stroke.mainloop()
def __init__(self, risk_factor, res): root_CHD = Tk() root_CHD.title("Diagnosing CHD") root_CHD.geometry("1400x750") print("Here") CHD_r_1 = StringVar() CHD_r_2 = StringVar() CHD_r_3 = StringVar() CHD_r_4 = StringVar() CHD_r_5 = StringVar() CHD_r_6 = StringVar() CHD_r_7 = StringVar() CHD_my_canvas = Canvas(root_CHD) CHD_my_canvas.pack(side=LEFT, fill=BOTH,expand=1) # Background: CHD_img = Image.open("background.png") CHD_img = CHD_img.resize((1800,1280), Image.ANTIALIAS) CHD_bg = ImageTk.PhotoImage(CHD_img) CHD_my_canvas.create_image(0,0, image=CHD_bg, anchor="nw") # Creating title text: CHD_my_canvas.create_text(650, 40, text="Answer some question", font=("Times", 20), fill="white") # quetion 1: CHD_my_canvas.create_text(240, 100, text="1) Do you observe blue tiny on skin ?", font=("helvetica", 15), fill="black") CHD_but_1 = Radiobutton(CHD_my_canvas, text="yes", variable=CHD_r_1, value="yes", fill="white", radius=8) CHD_but_1.put(120, 150) CHD_but_2 = Radiobutton(CHD_my_canvas, text="no", variable=CHD_r_1, value="no", fill="white", radius=8) CHD_but_2.put(220, 150) # CHD_r_1.set("yes") # question 2: CHD_my_canvas.create_text(230, 200, text="2) Are breathing fast than usual ?", font=("helvetica", 15), fill="black") CHD_but_3 = Radiobutton(CHD_my_canvas, text="yes", variable=CHD_r_2, value="yes", fill="white", radius=8) CHD_but_3.put(120, 250) CHD_but_4 = Radiobutton(CHD_my_canvas, text="no", variable=CHD_r_2, value="no", fill="white", radius=8) CHD_but_4.put(220, 250) # CHD_r_2.set("yes") # question 3: CHD_my_canvas.create_text(310, 300, text="3) Do you thing your heart beat is rapid than usual ?", font=("helvetica", 15), fill="black") CHD_but_5 = Radiobutton(CHD_my_canvas, text="yes", variable=CHD_r_3, value="yes", fill="white", radius=8) CHD_but_5.put(120, 350) CHD_but_6 = Radiobutton(CHD_my_canvas, text="no", variable=CHD_r_3, value="no", fill="white", radius=8) CHD_but_6.put(220, 350) # CHD_r_3.set("yes") # question 4: CHD_my_canvas.create_text(220, 400, text="4) Do you feel extreme fatigue ?", font=("helvetica", 15), fill="black") CHD_but_7 = Radiobutton(CHD_my_canvas, text="yes", variable=CHD_r_4, value="yes", fill="white", radius=8) CHD_but_7.put(120, 450) CHD_but_8 = Radiobutton(CHD_my_canvas, text="no", variable=CHD_r_4, value="no", fill="white", radius=8) CHD_but_8.put(220, 450) # CHD_r_4.set("yes") # question 5: CHD_my_canvas.create_text(220, 500, text="5) Do you faint during exersise ?", font=("helvetica", 15), fill="black") CHD_but_9 = Radiobutton(CHD_my_canvas, text="yes", variable=CHD_r_5, value="yes", fill="white", radius=8) CHD_but_9.put(120, 550) CHD_but_10 = Radiobutton(CHD_my_canvas, text="no", variable=CHD_r_5, value="no", fill="white", radius=8) CHD_but_10.put(220, 550) # CHD_r_5.set("male") # question 6: CHD_my_canvas.create_text(240, 600, text="6) Do you thik your breath is short ?", font=("helvetica", 15), fill="black") CHD_but_11 = Radiobutton(CHD_my_canvas, text="yes", variable=CHD_r_6, value="yes", fill="white", radius=8) CHD_but_11.put(120, 650) CHD_but_12 = Radiobutton(CHD_my_canvas, text="no", variable=CHD_r_6, value="no", fill="white", radius=8) CHD_but_12.put(220, 650) # CHD_r_6.set("yes") # question 7: CHD_my_canvas.create_text(900, 100, text="7) Do you have swelling in legs, tummy or ankels ?", font=("helvetica", 15), fill="black") CHD_but_13 = Radiobutton(CHD_my_canvas, text="yes", variable=CHD_r_7, value="yes", fill="white", radius=8) CHD_but_13.put(720, 150) CHD_but_14 = Radiobutton(CHD_my_canvas, text="no", variable=CHD_r_7, value="no", fill="white", radius=8) CHD_but_14.put(820, 150) # CHD_r_7.set("yes") # Creating object for prolog CHD_obj = ph.Prog() def calculate_fatality_risk(): global fatality_r CHD_que_1 = CHD_r_1.get() CHD_que_2 = CHD_r_2.get() CHD_que_3 = CHD_r_3.get() CHD_que_4 = CHD_r_4.get() CHD_que_5 = CHD_r_5.get() CHD_que_6 = CHD_r_6.get() CHD_que_7 = CHD_r_7.get() print(CHD_que_1) print(CHD_que_2) print(CHD_que_3) print(CHD_que_4) print(CHD_que_5) print(CHD_que_6) print(CHD_que_7) fatality_r = CHD_obj.diagnose_congenital_heart_disease(CHD_que_1,CHD_que_2, CHD_que_3, CHD_que_4, CHD_que_5, CHD_que_6, CHD_que_7, risk_factor) print("Returned value is : " + str(fatality_r)) print("Your fatality risk is : " + str(fatality_r) + "%") message_CHD_res = messagebox.showinfo("Risk factor ", "Your fatality risk is : " + str(fatality_r) + "%") if message_CHD_res == 'ok': if fatality_r > 0 : root_CHD.destroy() Result.GUI_result("Congenital Heart Disease", fatality_r, risk_factor, res) else: root_CHD.destroy() CAD.GUI_CAD(risk_factor, res) #Result.GUI_result("Unkown", fatality_r, risk_factor) print("Back here in GUI_CHD") but_To_result = ttk.Button(CHD_my_canvas, text="submit", width=18, command=calculate_fatality_risk) CHD_my_canvas.create_window(870, 550, window=but_To_result) root_CHD.mainloop()
def __init__(self, risk_factor, res): root_arr = Tk() root_arr.title("Diagnosis Arrythmias") cent = "1000x660+160+40" root_arr.geometry(cent) print("In GUI_arrythmias") arr_r_1 = StringVar() arr_r_2 = StringVar() arr_r_3 = StringVar() arr_r_4 = StringVar() # Setting up Canvas arr_my_canvas = Canvas(root_arr) arr_my_canvas.pack(side=LEFT, fill=BOTH, expand=1) #Background arr_img = Image.open("background.png") arr_img = arr_img.resize((1800, 1280), Image.ANTIALIAS) arr_bg = ImageTk.PhotoImage(arr_img) arr_my_canvas.create_image(0, 0, image=arr_bg, anchor="nw") # Creating title text: arr_my_canvas.create_text(520, 40, text="Answer some question", font=("Times", 20), fill="white") # quetion 1: arr_my_canvas.create_text(200, 100, text="1) Do you have fluttering in chest ?", font=("helvetica", 15), fill="black") arr_but_1 = Radiobutton(arr_my_canvas, text="yes", variable=arr_r_1, value="yes", fill="white", radius=8) arr_but_1.put(90, 150) arr_but_2 = Radiobutton(arr_my_canvas, text="no", variable=arr_r_1, value="no", fill="white", radius=8) arr_but_2.put(180, 150) # arr_r_1.set("yes") # question 2: arr_my_canvas.create_text(180, 200, text="2) Do you have chest pain ?", font=("helvetica", 15), fill="black") arr_but_3 = Radiobutton(arr_my_canvas, text="yes", variable=arr_r_2, value="yes", fill="white", radius=8) arr_but_3.put(90, 250) arr_but_4 = Radiobutton(arr_my_canvas, text="no", variable=arr_r_2, value="no", fill="white", radius=8) arr_but_4.put(180, 250) # arr_r_2.set("often") # question 3: arr_my_canvas.create_text(160, 300, text="3) Do you feel fainting ?", font=("helvetica", 15), fill="black") arr_but_5 = Radiobutton(arr_my_canvas, text="yes", variable=arr_r_3, value="yes", fill="white", radius=8) arr_but_5.put(90, 350) arr_but_6 = Radiobutton(arr_my_canvas, text="no", variable=arr_r_3, value="no", fill="white", radius=8) arr_but_6.put(180, 350) # arr_r_3.set("often") # question 4: arr_my_canvas.create_text(150, 400, text="4) Do you feel dizzy ?", font=("helvetica", 15), fill="black") arr_but_7 = Radiobutton(arr_my_canvas, text="yes", variable=arr_r_4, value="yes", fill="white", radius=8) arr_but_7.put(90, 450) arr_but_8 = Radiobutton(arr_my_canvas, text="no", variable=arr_r_4, value="no", fill="white", radius=8) arr_but_8.put(180, 450) # arr_r_4.set("often") # Creating arr_object of prog arr_obj = ph.Prog() def calculate_fatality_risk(): #Taking response form radio button #global risk_factor global fatality_r arr_que_1 = arr_r_1.get() arr_que_2 = arr_r_2.get() arr_que_3 = arr_r_3.get() arr_que_4 = arr_r_4.get() print(arr_que_1) print(arr_que_2) print(arr_que_3) print(arr_que_4) fatality_r = arr_obj.diagnose_Arrythmias(arr_que_1, arr_que_2, arr_que_3, arr_que_4, risk_factor) print("Returned value is : " + str(fatality_r)) print("Your fatality risk is : " + str(fatality_r) + "%") message_arr_res = messagebox.showinfo( "Risk factor ", "Your fatality risk is : " + str(fatality_r) + "%") if message_arr_res == 'ok': if fatality_r > 0: root_arr.destroy() Result.GUI_result("Arrythmias", fatality_r, risk_factor, res) else: root_arr.destroy() CHD.GUI_CHD(risk_factor, res) #Result.GUI_result("Unkown", fatality_r, risk_factor) print("Back here in GUI_arrythmias") but_To_result = ttk.Button(arr_my_canvas, text="submit", width=18, command=calculate_fatality_risk) arr_my_canvas.create_window(770, 550, window=but_To_result) root_arr.mainloop()