forked from coveros-matt-taylor/autoinsurance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
59 lines (46 loc) · 1.42 KB
/
app.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import tkinter as tk
from tkinter import OptionMenu as OptionMenu
from tkinter import StringVar as StringVar
from logic import *
def crunch():
claims = claims_var.get()
if claims == 0 or claims == 1:
claims = int(claims)
elif claims == "2-4":
claims = 3
elif claims == ">=5":
claims = 6
result = process(int(claims), int(age_entry.get()))
result_text = "Premium increase: ${} Warning Ltr: {} is canceled: {}".format(result.premium_increase, result.warning_letter_enum, result.is_policy_canceled)
print(result_text)
output_var.set(result_text)
window = tk.Tk()
output_var = StringVar(window)
output_var.set("Click the \"Crunch\" button to calculate your auto insurance results")
claims_label = tk.Label(text="Previous claims:")
claims_label.pack()
claims_var = StringVar(window)
claims_var.set("0")
claims_entry = OptionMenu(window, claims_var, "0", "1", "2-4", ">=5")
claims_entry.pack()
age_label = tk.Label(text="Driver's age:")
age_label.pack()
age_entry = tk.Entry(fg="black", bg="white", width=40)
age_entry.pack()
button = tk.Button(
text="Crunch",
width=12,
height=2,
bg="blue",
fg="yellow",
command=crunch
)
button.pack()
output = tk.Label(window, textvariable=output_var)
output.pack()
def handle_keypress(event):
# print(event.char)
selection = claims_var.get()
print(selection)
window.bind("<Key>", handle_keypress)
window.mainloop()