-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
76 lines (60 loc) · 2.41 KB
/
main.py
File metadata and controls
76 lines (60 loc) · 2.41 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import tkinter as tk
from tkinter import filedialog
from cal_OIF import calculate_OIF
def open_file(entry):
file_path = filedialog.askopenfilename()
entry.delete(0, tk.END)
entry.insert(0, file_path)
def clear_entries():
for entry in (entry_band_total, entry_band_group, entry_std_dev, entry_corr_coeff):
entry.delete(0, tk.END)
def start_cal():
num1 = entry_band_total.get()
num2 = entry_band_group.get()
filepath1 = entry_std_dev.get()
filepath2 = entry_corr_coeff.get()
print(num1,num2,filepath1,filepath2)
calculate_OIF(num1,num2,filepath1,filepath2)
root = tk.Tk()
root.title("OIF计算器")
# a部分: 界面标题
frame_a = tk.Frame(root)
frame_a.pack(pady=15)
label_title = tk.Label(frame_a, text="波段分组OIF计算", font=("等线", 24))
label_title.pack()
tk.Canvas(frame_a, height=2, bg="black", width=1)
# b部分: 输入框
frame_b = tk.Frame(root)
frame_b.pack(pady=15, padx=10)
# 总波段数
label_band_total = tk.Label(frame_b, text="总波段数")
label_band_total.grid(row=0, column=0, sticky=tk.W)
entry_band_total = tk.Entry(frame_b)
entry_band_total.grid(row=0, column=1)
# 每组波段数
label_band_group = tk.Label(frame_b, text="每组波段数")
label_band_group.grid(row=1, column=0, sticky=tk.W)
entry_band_group = tk.Entry(frame_b)
entry_band_group.grid(row=1, column=1)
# 标准差文件路径
label_std_dev = tk.Label(frame_b, text="标准差文件路径")
label_std_dev.grid(row=2, column=0, sticky=tk.W)
entry_std_dev = tk.Entry(frame_b)
entry_std_dev.grid(row=2, column=1)
button_std_dev = tk.Button(frame_b, text="打开文件", command=lambda: open_file(entry_std_dev))
button_std_dev.grid(row=2, column=2)
# 相关系数文件路径
label_corr_coeff = tk.Label(frame_b, text="相关系数文件路径")
label_corr_coeff.grid(row=3, column=0, sticky=tk.W)
entry_corr_coeff = tk.Entry(frame_b)
entry_corr_coeff.grid(row=3, column=1)
button_corr_coeff = tk.Button(frame_b, text="打开文件", command=lambda: open_file(entry_corr_coeff))
button_corr_coeff.grid(row=3, column=2)
# c部分: 按钮
frame_c = tk.Frame(root)
frame_c.pack(pady=15)
button_start = tk.Button(frame_c, text="开始计算", command=start_cal)
button_start.pack(side=tk.LEFT, padx=10)
button_clear = tk.Button(frame_c, text="清空输入", command=clear_entries)
button_clear.pack(side=tk.RIGHT, padx=10)
root.mainloop()