-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircleCal.py
More file actions
59 lines (44 loc) · 1.59 KB
/
Copy pathCircleCal.py
File metadata and controls
59 lines (44 loc) · 1.59 KB
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
from tkinter import ttk
import math
import time
main_window = tkinter.Tk()
main_window.title("circle calculator")
tab = ttk.Notebook(main_window)
main_tab = ttk.Frame(tab)
tab.add(main_tab, text="CIIIRRRCLLLLEE")
lable1 = ttk.Label(main_tab, text="Enter radiation:")
lable1.grid(row=0, column=0)
entry = ttk.Entry(main_tab)
entry.grid(row=1, column=0)
label2 = ttk.Label(main_tab, text="circumference")
label2.grid(row=2, column=0, columnspan=2)
label3 = ttk.Label(main_tab, text="extent")
label3.grid(row=2, column=2, columnspan=2)
result_circumference_label = ttk.Label(main_tab, text="")
result_circumference_label.grid(row=3, column=0, columnspan=2)
result_extent_label = ttk.Label(main_tab, text="")
result_extent_label.grid(row=3, column=2, columnspan=2)
def convert():
input = entry.get()
if input == "hi" or input == "hello":
result_circumference_label.config(text="Hello")
return
elif input == "bye":
main_window.destroy()
return
else:
try:
radiation = float(input)
circumference = radiation * math.pi * 2
extent = radiation ** 2 * math.pi
result_circumference_label.config(text=f"{circumference:.2f} ")
result_extent_label.config(text=f"{extent:.2f} ")
return
except ValueError:
entry.config(text="Value Error")
convert_button = ttk.Button(main_tab, text="Convert", command=convert)
convert_button.grid(row=4, column=0, columnspan=2)
main_window.bind("<Return>", lambda event: convert())
tab.pack(expand=1, fill="both")
main_window.mainloop()