-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculating of granular of oil
353 lines (150 loc) · 7.28 KB
/
Calculating of granular of oil
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# coding: utf-8
# import modules
from Tkinter import *
from tkMessageBox import *
root = Tk()
root.title('颗粒度平均值计算'.decode('gbk', 'ignore'))
frame_root = Frame(root)
frame_gran = Frame(frame_root)
# add labels in frame_gran
Label(frame_gran, text = '5μm:'.decode('gbk', 'ignore'), padx = 1, pady = 1).grid(row = 0)
e_5_1 = Entry(frame_gran)
e_5_1.grid(row = 0, column = 1, padx = 5, pady = 3)
e_5_2 = Entry(frame_gran)
e_5_2.grid(row = 0, column = 2, padx = 5, pady = 3)
e_5_3 = Entry(frame_gran)
e_5_3.grid(row = 0, column = 3, padx = 5, pady = 3)
Label(frame_gran, text = '15μm:'.decode('gbk', 'ignore'), padx = 1, pady = 1).grid(row = 1)
e_15_1 = Entry(frame_gran)
e_15_1.grid(row = 1, column = 1, padx = 5, pady = 3)
e_15_2 = Entry(frame_gran)
e_15_2.grid(row = 1, column = 2, padx = 5, pady = 3)
e_15_3 = Entry(frame_gran)
e_15_3.grid(row = 1, column = 3, padx = 5, pady = 3)
Label(frame_gran, text = '25μm:'.decode('gbk', 'ignore'), padx = 1, pady = 1).grid(row = 2)
e_25_1 = Entry(frame_gran)
e_25_1.grid(row = 2, column = 1, padx = 5, pady = 3)
e_25_2 = Entry(frame_gran)
e_25_2.grid(row = 2, column = 2, padx = 5, pady = 3)
e_25_3 = Entry(frame_gran)
e_25_3.grid(row = 2, column = 3, padx = 5, pady = 3)
Label(frame_gran, text = '50μm:'.decode('gbk', 'ignore'), padx = 1, pady = 1).grid(row = 3)
e_50_1 = Entry(frame_gran)
e_50_1.grid(row = 3, column = 1, padx = 5, pady = 3)
e_50_2 = Entry(frame_gran)
e_50_2.grid(row = 3, column = 2, padx = 5, pady = 3)
e_50_3 = Entry(frame_gran)
e_50_3.grid(row = 3, column = 3, padx = 5, pady = 3)
Label(frame_gran, text = '100μm:'.decode('gbk', 'ignore'), padx = 1, pady = 1).grid(row = 4)
e_100_1 = Entry(frame_gran)
e_100_1.grid(row = 4, column = 1, padx = 5, pady = 3)
e_100_2 = Entry(frame_gran)
e_100_2.grid(row = 4, column = 2, padx = 5, pady = 3)
e_100_3 = Entry(frame_gran)
e_100_3.grid(row = 4, column = 3, padx = 5, pady = 3)
# create a process symbol '===>>' to show the processing of calculate
Label(frame_gran, text = '===>>'.decode('gbk', 'ignore'), padx = 0, pady = 1).grid(row = 2, column = 4)
Label(frame_gran, text = '平均值:'.decode('gbk', 'ignore'), padx = 0, pady = 1).grid(row = 2, column = 5)
Label(frame_gran, text = '===>>'.decode('gbk', 'ignore'), padx = 0, pady = 1).grid(row = 2, column = 7)
Label(frame_gran, text = '级数:'.decode('gbk', 'ignore'), padx = 0, pady = 1).grid(row = 2, column = 8)
# make a dict to contain the levels and corresponding particle size
dict_levels = {'00': 125, '0': 250, '1': 500, '2': 1000, '3': 2000, '4': 4000, '5': 8000, '6': 16000, '7': 32000, '8': 64000,
'9': 128000, '10': 256000, '11': 512000, '12': 1024000}
def get_ave_to_level(*av):
'''
make sure the levels of every component according to the average of 5 components separately
'''
list_average = []
for average in av:
list_average.append(int(average))
list_average.sort()
for key in dict_levels:
if dict_levels[key] == list_average[4]:
return key
if dict_levels[key] < list_average[4] < dict_levels[key] * 2:
for key_1 in dict_levels:
if dict_levels[key_1] == dict_levels[key] * 2:
return key_1
if dict_levels['12'] < list_average[4]:
return '12'
var_5_ave = StringVar()
var_15_ave = StringVar()
var_25_ave = StringVar()
var_50_ave = StringVar()
var_100_ave = StringVar()
var_level = StringVar()
def show():
'''
Create labels to show the average and the level
'''
if (e_5_1.get() == '' or e_5_2.get() == '' or e_5_3.get() == '' or
e_15_1.get() == '' or e_15_2.get() == '' or e_15_3.get() == '' or
e_25_1.get() == '' or e_25_2.get() == '' or e_25_3.get() == '' or
e_50_1.get() == '' or e_50_2.get() == '' or e_50_3.get() == '' or
e_100_1.get() == '' or e_100_2.get() == '' or e_100_3.get() == ''):
showinfo(title = 'Error Warning', message = '输入有空白,请重新输入!'.decode('gbk', 'ignore'))
# calculate the average of five commponents separately
average_5 = (int(e_5_1.get()) + int(e_5_2.get()) + int(e_5_3.get())) / 3.00
average_5_round = round(average_5, 0)
average_15 = (int(e_15_1.get()) + int(e_15_2.get()) + int(e_15_3.get())) / 3.00
average_15_round = round(average_15, 0)
average_25 = (int(e_25_1.get()) + int(e_25_2.get()) + int(e_25_3.get())) / 3.00
average_25_round = round(average_25, 0)
average_50 = (int(e_50_1.get()) + int(e_50_2.get()) + int(e_50_3.get())) / 3.00
average_50_round = round(average_50, 0)
average_100 = (int(e_100_1.get()) + int(e_100_2.get()) + int(e_100_3.get())) / 3.00
average_100_round = round(average_100, 0)
var_5_ave.set(str(average_5_round))
var_15_ave.set(str(average_15_round))
var_25_ave.set(str(average_25_round))
var_50_ave.set(str(average_50_round))
var_100_ave.set(str(average_100_round))
# show the average of every component
Label(frame_gran, textvariable = var_5_ave).grid(row = 0, column = 6)
Label(frame_gran, textvariable = var_15_ave).grid(row = 1, column = 6)
Label(frame_gran, textvariable = var_25_ave).grid(row = 2, column = 6)
Label(frame_gran, textvariable = var_50_ave).grid(row = 3, column = 6)
Label(frame_gran, textvariable = var_100_ave).grid(row = 4, column = 6)
# calculate the level according to the average of every component
level_result = get_ave_to_level(average_5_round, average_15_round, average_25_round, average_50_round, average_100_round)
var_level.set(level_result)
# show the level of the group of numbers
Label(frame_gran, textvariable = var_level).grid(row = 2, column = 9)
def clr():
'''
Clear the content of components
'''
e_5_1.delete(0, END)
e_5_2.delete(0, END)
e_5_3.delete(0, END)
e_15_1.delete(0, END)
e_15_2.delete(0, END)
e_15_3.delete(0, END)
e_25_1.delete(0, END)
e_25_2.delete(0, END)
e_25_3.delete(0, END)
e_50_1.delete(0, END)
e_50_2.delete(0, END)
e_50_3.delete(0, END)
e_100_1.delete(0, END)
e_100_2.delete(0, END)
e_100_3.delete(0, END)
var_5_ave.set('')
var_15_ave.set('')
var_25_ave.set('')
var_50_ave.set('')
var_100_ave.set('')
var_level.set('')
# show the average of every component and the level of the result
Label(frame_gran, textvariable = var_5_ave).grid(row = 0, column = 6)
Label(frame_gran, textvariable = var_15_ave).grid(row = 1, column = 6)
Label(frame_gran, textvariable = var_25_ave).grid(row = 2, column = 6)
Label(frame_gran, textvariable = var_50_ave).grid(row = 3, column = 6)
Label(frame_gran, textvariable = var_100_ave).grid(row = 4, column = 6)
Label(frame_gran, textvariable = var_level).grid(row = 2, column = 9)
Button(frame_gran, text = '计算'.decode('gbk', 'ignore'), command = show).grid(row = 6, column = 1, padx = 10, pady = 3)
Button(frame_gran, text = '清空'.decode('gbk', 'ignore'), command = clr).grid(row = 6, column = 2, padx = 10, pady = 3)
Button(frame_gran, text = '退出'.decode('gbk', 'ignore'), command = root.quit).grid(row = 6, column = 3, padx = 10, pady = 3)
frame_gran.pack(padx = 10, pady = 5)
frame_root.pack(padx = 10, pady = 5)
mainloop()