-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
138 lines (93 loc) · 4.01 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import tkinter as tk
import math
def calculate_palettes():
cubic_meters_input = cubic_meters_entry.get()
size_input = size_entry.get()
if cubic_meters_input.lower() == 'finish' or size_input.lower() == 'finish':
return
cubic_meters = int(cubic_meters_input)
size = int(size_input)
if size == 10 or size == 15:
palette = math.ceil(cubic_meters / 1.8)
main_cubic_meters = palette * 1.8
elif size == 20:
palette = math.ceil(cubic_meters / 1.92)
main_cubic_meters = palette * 1.92
else:
output_text.insert(tk.END, "Your size is not correct\n")
return
main_palette = int(palette)
output_text.insert(tk.END, "Result {}: Your palette is: {}\n".format(calculate_palettes.counter, main_palette))
output_text.insert(tk.END, "Your main cubic meters is: {}\n".format(main_cubic_meters))
glue = main_cubic_meters * 20
output_text.insert(tk.END, "Your glue is: {}\n".format(glue))
bag = math.ceil(glue / 30)
output_text.insert(tk.END, "Your bag is: {}\n".format(bag))
main_glue = bag * 30
output_text.insert(tk.END, "Your main glue is: {}\n".format(main_glue))
glue_palette = math.ceil(main_glue / 720)
output_text.insert(tk.END, "Your glue palette is: {}\n".format(glue_palette))
all_palette = main_palette + glue_palette
output_text.insert(tk.END, "Your all palette is: {}\n".format(all_palette))
truck = math.floor(cubic_meters / 18)
output_text.insert(tk.END, "Your truck is: {}\n".format(truck))
bag_truck = truck * 18
output_text.insert(tk.END, "Your bag is: {}\n".format(bag_truck))
output_text.insert(tk.END, "-"*30 + "\n")
calculate_palettes.results.append({
'main_palette': main_palette,
'main_cubic_meters': main_cubic_meters,
'glue': glue,
'bag': bag,
'main_glue': main_glue,
'glue_palette': glue_palette,
'all_palette': all_palette,
'truck': truck,
'bag_truck': bag_truck
})
cubic_meters_entry.delete(0, tk.END)
size_entry.delete(0, tk.END)
calculate_palettes.counter += 1
calculate_palettes.counter = 1
calculate_palettes.results = []
def calculate_sum():
if not calculate_palettes.results:
output_text.insert(tk.END, "No results to calculate sum.\n")
return
output_text.delete("1.0", tk.END)
sum_data = {}
for data in calculate_palettes.results:
for key, value in data.items():
sum_data[key] = sum_data.get(key, 0) + value
output_text.insert(tk.END, "===== Sum of All Data =====\n")
for key, value in sum_data.items():
output_text.insert(tk.END, "{}: {}\n".format(key, value))
output_text.insert(tk.END, "===========================\n")
app = tk.Tk()
app.title("Palette Calculator")
cubic_meters_frame = tk.Frame(app)
cubic_meters_frame.pack(fill=tk.X, padx=10, pady=5)
cubic_meters_label = tk.Label(cubic_meters_frame, text="مقدار هبلکس را وارد کنید:")
cubic_meters_label.pack(side=tk.RIGHT)
cubic_meters_entry = tk.Entry(cubic_meters_frame)
cubic_meters_entry.pack(side=tk.RIGHT, expand=True, fill=tk.X)
size_frame = tk.Frame(app)
size_frame.pack(fill=tk.X, padx=10, pady=5)
size_label = tk.Label(size_frame, text= "سایز را وارد کنید:")
size_label.pack(side=tk.RIGHT)
size_entry = tk.Entry(size_frame)
size_entry.pack(side=tk.RIGHT, expand=True, fill=tk.X)
output_text = tk.Text(app, height=20, width=60)
output_text.pack(fill=tk.BOTH, padx=10, pady=5, expand=True)
calculate_button = tk.Button(app, text="محاسبه", command=calculate_palettes)
calculate_button.pack(side=tk.LEFT, padx=5, pady=5)
# Finish Button
finish_button = tk.Button(app, text="پایان", command=calculate_sum)
finish_button.pack(side=tk.LEFT, padx=5, pady=5)
def on_first_entry_return(event):
size_entry.focus_set()
def on_second_entry_return(event):
calculate_button.invoke()
cubic_meters_entry.bind("<Return>", on_first_entry_return)
size_entry.bind("<Return>", on_second_entry_return)
app.mainloop()