mg-pso-gui 0.1.13__py3-none-any.whl → 0.2.75__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/METADATA +10 -11
- mg_pso_gui-0.2.75.dist-info/RECORD +76 -0
- {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/WHEEL +1 -1
- mgpsogui/gui/General/ParameterView.py +110 -0
- mgpsogui/gui/General/__init__.py +0 -0
- mgpsogui/gui/HomePage.py +565 -513
- mgpsogui/gui/OptionManager.py +333 -145
- mgpsogui/gui/OptionManager_backup.py +443 -0
- mgpsogui/gui/PlatformTab/PlatformTab.py +15 -6
- mgpsogui/gui/RunTab/OptimalParameterView.py +47 -0
- mgpsogui/gui/RunTab/RunTab.py +89 -35
- mgpsogui/gui/SetupTab/BoundsEditorWindow.py +1 -1
- mgpsogui/gui/SetupTab/BoundsList.py +97 -34
- mgpsogui/gui/SetupTab/CustomFunctionEditorWindow.py +74 -0
- mgpsogui/gui/SetupTab/CustomFunctionMetrics.py +156 -0
- mgpsogui/gui/SetupTab/FunctionsList.py +60 -6
- mgpsogui/gui/SetupTab/{StaticParameterView.py → ListEditor.py} +27 -16
- mgpsogui/gui/SetupTab/ListParametersView.py +7 -6
- mgpsogui/gui/SetupTab/{CalibrationParametersView.py → OverrideParameterMetrics.py} +35 -9
- mgpsogui/gui/SetupTab/OverrideParameterWindow.py +40 -0
- mgpsogui/gui/SetupTab/SetupTab.py +31 -11
- mgpsogui/gui/SetupTab/StepView.py +93 -22
- mgpsogui/gui/VisualizeTab/MatrixEditor.py +68 -0
- mgpsogui/gui/VisualizeTab/SideBar.py +399 -0
- mgpsogui/gui/VisualizeTab/VisualizeTab.py +76 -11
- mgpsogui/gui/defaults/__init__.py +0 -0
- mgpsogui/gui/defaults/optimization.json +176 -0
- mgpsogui/gui/defaults/sampling.json +111 -0
- mgpsogui/gui/defaults/sensitivity.json +20 -0
- mgpsogui/gui/images/plus.png +0 -0
- mgpsogui/gui/images/test.png +0 -0
- mgpsogui/util/GraphGenerator.py +747 -42
- mgpsogui/util/PSORunner.py +608 -116
- mgpsogui/util/debug.py +559 -0
- mgpsogui/util/helpers.py +95 -0
- mgpsogui/util/recosu/__init__.py +2 -1
- mgpsogui/util/recosu/pso/csip_access.py +2 -35
- mgpsogui/util/recosu/pso/pso.py +55 -59
- mgpsogui/util/recosu/sampling/__init__.py +16 -0
- mgpsogui/util/recosu/sampling/halton/__init__.py +0 -0
- mgpsogui/util/recosu/sampling/halton/halton.py +45 -0
- mgpsogui/util/recosu/sampling/halton/prime.py +82 -0
- mgpsogui/util/recosu/sampling/random/__init__.py +0 -0
- mgpsogui/util/recosu/sampling/random/random_sampler.py +34 -0
- mgpsogui/util/recosu/sampling/sample_trace_writer.py +47 -0
- mgpsogui/util/recosu/sampling/sampler_task.py +75 -0
- mgpsogui/util/recosu/sampling/sampling.py +99 -0
- mgpsogui/util/sampler_test_driver.py +129 -0
- mg_pso_gui-0.1.13.dist-info/RECORD +0 -50
- mgpsogui/gui/images/IGOW 4 Logo.png +0 -0
- {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/entry_points.txt +0 -0
- {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,399 @@
|
|
1
|
+
from customtkinter import CTkScrollableFrame
|
2
|
+
from customtkinter import CTkFrame
|
3
|
+
from customtkinter import CTkLabel
|
4
|
+
from customtkinter import CTkButton
|
5
|
+
from customtkinter import CTkEntry
|
6
|
+
from customtkinter import CTkTextbox
|
7
|
+
from customtkinter import CTkImage
|
8
|
+
from customtkinter import CTkOptionMenu
|
9
|
+
from PIL import Image
|
10
|
+
import os
|
11
|
+
|
12
|
+
from . import MatrixEditor as me
|
13
|
+
|
14
|
+
import pandas as pd
|
15
|
+
|
16
|
+
class SideBar(CTkScrollableFrame):
|
17
|
+
def __init__(self, *args,
|
18
|
+
option_manager: None,
|
19
|
+
home_page: None,
|
20
|
+
**kwargs):
|
21
|
+
super().__init__(*args, **kwargs)
|
22
|
+
|
23
|
+
self.option_manager = option_manager
|
24
|
+
self.home_page = home_page
|
25
|
+
|
26
|
+
self.render()
|
27
|
+
|
28
|
+
def clear(self):
|
29
|
+
self.containerFrame.destroy()
|
30
|
+
|
31
|
+
def refresh(self):
|
32
|
+
self.clear()
|
33
|
+
self.render()
|
34
|
+
|
35
|
+
def render(self):
|
36
|
+
|
37
|
+
self.containerFrame = CTkFrame(self, width=300, fg_color="transparent")
|
38
|
+
self.containerFrame.grid(row=0, column=0, padx=(
|
39
|
+
0, 0), pady=(0, 0), sticky="ew")
|
40
|
+
self.containerFrame.grid_columnconfigure(0, weight=1)
|
41
|
+
|
42
|
+
selected_graph = self.option_manager.get("selected_graph").get()
|
43
|
+
|
44
|
+
if (selected_graph == "Best Cost Stacked"):
|
45
|
+
#self.graph_label = CTkLabel(self.containerFrame, text="Best Cost Stacked")
|
46
|
+
#self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
47
|
+
pass
|
48
|
+
elif (selected_graph == "Best Cost by Round"):
|
49
|
+
#self.graph_label = CTkLabel(self.containerFrame, text="Best Cost by Round")
|
50
|
+
#self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
51
|
+
pass
|
52
|
+
elif (selected_graph == "Iteration Table"):
|
53
|
+
#self.graph_label = CTkLabel(self.containerFrame, text="Iteration Table")
|
54
|
+
#self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
55
|
+
pass
|
56
|
+
elif (selected_graph == "Calibrated Parameters"):
|
57
|
+
#self.graph_label = CTkLabel(self.containerFrame, text="Calibrated Parameters")
|
58
|
+
#self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
59
|
+
pass
|
60
|
+
elif (selected_graph == "Custom CSV"):
|
61
|
+
|
62
|
+
folder = self.option_manager.get_project_folder()
|
63
|
+
if not os.path.exists(folder):
|
64
|
+
os.makedirs(folder)
|
65
|
+
|
66
|
+
# Get all CSV files in the folder and add their paths to a list
|
67
|
+
path_map = {}
|
68
|
+
name_list = []
|
69
|
+
for root, dirs, files in os.walk(folder):
|
70
|
+
for file in files:
|
71
|
+
if file.endswith(".csv"):
|
72
|
+
name = file.replace(".csv", "")
|
73
|
+
name_list.append(name)
|
74
|
+
path_map[name] = os.path.join(root, file)
|
75
|
+
|
76
|
+
if (len(name_list) == 0):
|
77
|
+
name_list.append("No files found...")
|
78
|
+
else:
|
79
|
+
if (self.option_manager.get("selected_csv").get() not in name_list):
|
80
|
+
self.option_manager.get("selected_csv").set(name_list[0])
|
81
|
+
|
82
|
+
file_label = CTkLabel(self.containerFrame, text="CSV File:")
|
83
|
+
file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
84
|
+
|
85
|
+
self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.option_manager.get("selected_csv"), command=self.home_page.update_graph)
|
86
|
+
self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
87
|
+
|
88
|
+
selected_file = self.option_manager.get("selected_csv").get()
|
89
|
+
if (selected_file in path_map and selected_file != self.home_page.open_file):
|
90
|
+
self.home_page.csv_data = self.load_special_csv(path_map[selected_file])
|
91
|
+
print(self.home_page.csv_data)
|
92
|
+
self.home_page.open_file = selected_file
|
93
|
+
|
94
|
+
if (self.home_page.csv_data is not None):
|
95
|
+
# Get all column names of CSV
|
96
|
+
columns = self.home_page.csv_data["data"].columns
|
97
|
+
|
98
|
+
x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
|
99
|
+
x_axis_label.grid(row=2, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
|
100
|
+
|
101
|
+
self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
|
102
|
+
self.home_page.csv_x_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
103
|
+
|
104
|
+
if (self.home_page.csv_x_selector.get() not in columns):
|
105
|
+
self.home_page.csv_x_selector.set(columns[1])
|
106
|
+
|
107
|
+
y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
|
108
|
+
y1_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
109
|
+
|
110
|
+
self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
|
111
|
+
self.home_page.csv_y1_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
112
|
+
|
113
|
+
if (self.home_page.csv_y1_selector.get() not in columns):
|
114
|
+
self.home_page.csv_y1_selector.set(columns[2])
|
115
|
+
|
116
|
+
y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
|
117
|
+
y2_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
118
|
+
|
119
|
+
self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
|
120
|
+
self.home_page.csv_y2_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
121
|
+
|
122
|
+
if (self.home_page.csv_y2_selector.get() not in columns):
|
123
|
+
self.home_page.csv_y2_selector.set(columns[3])
|
124
|
+
|
125
|
+
elif (selected_graph == "Compare CSV"):
|
126
|
+
folder = self.option_manager.get_project_folder()
|
127
|
+
if not os.path.exists(folder):
|
128
|
+
os.makedirs(folder)
|
129
|
+
|
130
|
+
# Get all CSV files in the folder and add their paths to a list
|
131
|
+
path_map = {}
|
132
|
+
name_list = []
|
133
|
+
for root, dirs, files in os.walk(folder):
|
134
|
+
for file in files:
|
135
|
+
if file.endswith(".csv"):
|
136
|
+
name = file.replace(".csv", "")
|
137
|
+
name_list.append(name)
|
138
|
+
path_map[name] = os.path.join(root, file)
|
139
|
+
|
140
|
+
if (len(name_list) == 0):
|
141
|
+
name_list.append("No files found...")
|
142
|
+
else:
|
143
|
+
if (self.option_manager.get("selected_csv").get() not in name_list):
|
144
|
+
self.option_manager.get("selected_csv").set(name_list[0])
|
145
|
+
if (self.option_manager.get("selected_csv2").get() not in name_list):
|
146
|
+
self.option_manager.get("selected_csv2").set(name_list[0])
|
147
|
+
|
148
|
+
file_label = CTkLabel(self.containerFrame, text="CSV Files:")
|
149
|
+
file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
150
|
+
|
151
|
+
self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.option_manager.get("selected_csv"), command=self.home_page.update_graph)
|
152
|
+
self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
153
|
+
|
154
|
+
self.home_page.csv_file_selector2 = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.option_manager.get("selected_csv2"), command=self.home_page.update_graph)
|
155
|
+
self.home_page.csv_file_selector2.grid(row=2, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
156
|
+
|
157
|
+
selected_file = self.option_manager.get("selected_csv").get()
|
158
|
+
if (selected_file in path_map and selected_file != self.home_page.open_file):
|
159
|
+
self.home_page.csv_data = self.load_special_csv(path_map[selected_file])
|
160
|
+
print(self.home_page.csv_data)
|
161
|
+
self.home_page.open_file = selected_file
|
162
|
+
|
163
|
+
selected_file2 = self.option_manager.get("selected_csv2").get()
|
164
|
+
if (selected_file2 in path_map and selected_file2 != self.home_page.open_file2):
|
165
|
+
self.home_page.csv_data2 = self.load_special_csv(path_map[selected_file2])
|
166
|
+
print(self.home_page.csv_data2)
|
167
|
+
self.home_page.open_file2 = selected_file2
|
168
|
+
|
169
|
+
if (self.home_page.csv_data is not None and self.home_page.csv_data2 is not None):
|
170
|
+
# Get all column names of CSV
|
171
|
+
columns = self.home_page.csv_data["data"].columns
|
172
|
+
columns2 = self.home_page.csv_data2["data"].columns
|
173
|
+
|
174
|
+
x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
|
175
|
+
x_axis_label.grid(row=3, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
|
176
|
+
|
177
|
+
self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
|
178
|
+
self.home_page.csv_x_selector.grid(row=4, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
179
|
+
|
180
|
+
if (self.home_page.csv_x_selector.get() not in columns):
|
181
|
+
self.home_page.csv_x_selector.set(columns[1])
|
182
|
+
|
183
|
+
y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
|
184
|
+
y1_axis_label.grid(row=5, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
185
|
+
|
186
|
+
self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
|
187
|
+
self.home_page.csv_y1_selector.grid(row=6, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
188
|
+
|
189
|
+
if (self.home_page.csv_y1_selector.get() not in columns):
|
190
|
+
self.home_page.csv_y1_selector.set(columns[2])
|
191
|
+
|
192
|
+
y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
|
193
|
+
y2_axis_label.grid(row=7, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
194
|
+
|
195
|
+
self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns2, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
|
196
|
+
self.home_page.csv_y2_selector.grid(row=8, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
197
|
+
|
198
|
+
if (self.home_page.csv_y2_selector.get() not in columns2):
|
199
|
+
self.home_page.csv_y2_selector.set(columns2[2])
|
200
|
+
|
201
|
+
elif (selected_graph == "Sampling CSV"):
|
202
|
+
|
203
|
+
folder = self.option_manager.get_project_folder()
|
204
|
+
if not os.path.exists(folder):
|
205
|
+
os.makedirs(folder)
|
206
|
+
|
207
|
+
# Get all CSV files in the folder and add their paths to a list
|
208
|
+
path_map = {}
|
209
|
+
name_list = []
|
210
|
+
for root, dirs, files in os.walk(folder):
|
211
|
+
for file in files:
|
212
|
+
if file.endswith(".csv"):
|
213
|
+
name = file.replace(".csv", "")
|
214
|
+
name_list.append(name)
|
215
|
+
path_map[name] = os.path.join(root, file)
|
216
|
+
|
217
|
+
if (len(name_list) == 0):
|
218
|
+
name_list.append("No files found...")
|
219
|
+
else:
|
220
|
+
if (self.option_manager.get("selected_csv").get() not in name_list):
|
221
|
+
self.option_manager.get("selected_csv").set(name_list[0])
|
222
|
+
|
223
|
+
file_label = CTkLabel(self.containerFrame, text="CSV File:")
|
224
|
+
file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
225
|
+
|
226
|
+
self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.option_manager.get("selected_csv"), command=self.home_page.update_graph)
|
227
|
+
self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
228
|
+
|
229
|
+
selected_file = self.option_manager.get("selected_csv").get()
|
230
|
+
if (selected_file in path_map and selected_file != self.home_page.open_file):
|
231
|
+
self.home_page.csv_data = pd.read_csv(path_map[selected_file])
|
232
|
+
print(self.home_page.csv_data)
|
233
|
+
self.home_page.open_file = selected_file
|
234
|
+
|
235
|
+
if (self.home_page.csv_data is not None):
|
236
|
+
# Get all column names of CSV
|
237
|
+
columns = self.home_page.csv_data.columns
|
238
|
+
|
239
|
+
x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
|
240
|
+
x_axis_label.grid(row=2, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
|
241
|
+
|
242
|
+
self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
|
243
|
+
self.home_page.csv_x_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
244
|
+
|
245
|
+
if (self.home_page.csv_x_selector.get() not in columns):
|
246
|
+
self.home_page.csv_x_selector.set(columns[1])
|
247
|
+
|
248
|
+
y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
|
249
|
+
y1_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
250
|
+
|
251
|
+
self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
|
252
|
+
self.home_page.csv_y1_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
253
|
+
|
254
|
+
if (self.home_page.csv_y1_selector.get() not in columns):
|
255
|
+
self.home_page.csv_y1_selector.set(columns[2])
|
256
|
+
|
257
|
+
y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
|
258
|
+
y2_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
259
|
+
|
260
|
+
self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
|
261
|
+
self.home_page.csv_y2_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
262
|
+
|
263
|
+
if (self.home_page.csv_y2_selector.get() not in columns):
|
264
|
+
self.home_page.csv_y2_selector.set(columns[3])
|
265
|
+
|
266
|
+
style_label = CTkLabel(self.containerFrame, text="Figure Style:")
|
267
|
+
style_label.grid(row=8, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
268
|
+
|
269
|
+
self.home_page.figure_style_selector = CTkOptionMenu(self.containerFrame, values=["Scatter", "Bars", "Lines", "Area", "Box"], variable=self.option_manager.get("figure_style"), command=self.home_page.update_graph)
|
270
|
+
self.home_page.figure_style_selector.grid(row=9, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
271
|
+
|
272
|
+
elif (selected_graph == "Matrix Editor"):
|
273
|
+
|
274
|
+
folder = self.option_manager.get_project_folder()
|
275
|
+
if not os.path.exists(folder):
|
276
|
+
os.makedirs(folder)
|
277
|
+
|
278
|
+
# Get all CSV files in the folder and add their paths to a list
|
279
|
+
path_map = {}
|
280
|
+
name_list = []
|
281
|
+
for root, dirs, files in os.walk(folder):
|
282
|
+
for file in files:
|
283
|
+
if file.endswith(".csv"):
|
284
|
+
name = file.replace(".csv", "")
|
285
|
+
name_list.append(name)
|
286
|
+
path_map[name] = os.path.join(root, file)
|
287
|
+
|
288
|
+
if (len(name_list) == 0):
|
289
|
+
name_list.append("No files found...")
|
290
|
+
else:
|
291
|
+
if (self.option_manager.get("selected_csv").get() not in name_list):
|
292
|
+
self.option_manager.get("selected_csv").set(name_list[0])
|
293
|
+
|
294
|
+
file_label = CTkLabel(self.containerFrame, text="CSV File:")
|
295
|
+
file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
296
|
+
|
297
|
+
self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.option_manager.get("selected_csv"), command=self.home_page.update_graph)
|
298
|
+
self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
299
|
+
|
300
|
+
selected_file = self.option_manager.get("selected_csv").get()
|
301
|
+
if (selected_file in path_map and selected_file != self.home_page.open_file):
|
302
|
+
self.home_page.csv_data = pd.read_csv(path_map[selected_file])
|
303
|
+
print(self.home_page.csv_data)
|
304
|
+
self.home_page.open_file = selected_file
|
305
|
+
|
306
|
+
if (self.home_page.csv_data is not None):
|
307
|
+
# Get all column names of CSV
|
308
|
+
columns = self.home_page.csv_data.columns
|
309
|
+
|
310
|
+
style_label = CTkLabel(self.containerFrame, text="Figure Style:")
|
311
|
+
style_label.grid(row=2, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
312
|
+
|
313
|
+
self.home_page.figure_style_selector = CTkOptionMenu(self.containerFrame, values=["Scatter", "Bars", "Lines", "Area", "Box"], variable=self.option_manager.get("figure_style"), command=self.home_page.update_graph)
|
314
|
+
self.home_page.figure_style_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
315
|
+
|
316
|
+
x_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
|
317
|
+
x_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
|
318
|
+
|
319
|
+
self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
|
320
|
+
self.home_page.csv_x_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
321
|
+
|
322
|
+
if (self.home_page.csv_x_selector.get() not in columns):
|
323
|
+
self.home_page.csv_x_selector.set(columns[1])
|
324
|
+
|
325
|
+
self.matrix_editor = me.MatrixEditor(self.containerFrame, width=280, option_manager=self.option_manager, home_page=self.home_page, columns=columns)
|
326
|
+
self.matrix_editor.grid(row=6, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
|
327
|
+
self.matrix_editor.grid_columnconfigure(0, weight=1)
|
328
|
+
self.matrix_editor.grid_rowconfigure(0, weight=1)
|
329
|
+
|
330
|
+
|
331
|
+
#y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
|
332
|
+
#y1_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
333
|
+
|
334
|
+
#self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
|
335
|
+
#self.home_page.csv_y1_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
336
|
+
|
337
|
+
#if (self.home_page.csv_y1_selector.get() not in columns):
|
338
|
+
# self.home_page.csv_y1_selector.set(columns[2])
|
339
|
+
|
340
|
+
def load_special_csv(self, file_path):
|
341
|
+
file_metadata = {}
|
342
|
+
data_metadata = {}
|
343
|
+
mode = "file_metadata"
|
344
|
+
columns = []
|
345
|
+
data_lines = []
|
346
|
+
|
347
|
+
with open(file_path, "r") as file:
|
348
|
+
lines = file.readlines()
|
349
|
+
|
350
|
+
if (not lines[0].startswith("@")):
|
351
|
+
return {
|
352
|
+
"file_attributes": {},
|
353
|
+
"data_attributes": {},
|
354
|
+
"data": pd.read_csv(file_path)
|
355
|
+
}
|
356
|
+
|
357
|
+
for line in lines:
|
358
|
+
if (line.startswith("@H,")):
|
359
|
+
mode = "data_metadata"
|
360
|
+
columns = line.strip().rstrip(",").split(",")[1:]
|
361
|
+
continue
|
362
|
+
elif (line.startswith("@T,")):
|
363
|
+
mode = "file_metadata"
|
364
|
+
continue
|
365
|
+
elif (line.startswith(",") and mode == "data_metadata"):
|
366
|
+
mode = "file_data"
|
367
|
+
|
368
|
+
if (mode == "file_metadata"):
|
369
|
+
try:
|
370
|
+
key, value = line.strip().rstrip(",").split(",")
|
371
|
+
file_metadata[key] = value
|
372
|
+
except:
|
373
|
+
pass
|
374
|
+
|
375
|
+
elif (mode == "data_metadata"):
|
376
|
+
try:
|
377
|
+
values = line.strip().rstrip(",").split(",")
|
378
|
+
key = values[0]
|
379
|
+
values = values[1:]
|
380
|
+
if len(values) == len(columns):
|
381
|
+
data_metadata[key] = {}
|
382
|
+
for i in range(len(columns)):
|
383
|
+
data_metadata[key][columns[i]] = values[i]
|
384
|
+
except:
|
385
|
+
pass
|
386
|
+
|
387
|
+
elif (mode == "file_data"):
|
388
|
+
try:
|
389
|
+
values = line.strip().rstrip(",").split(",")[1:]
|
390
|
+
if len(values) == len(columns):
|
391
|
+
data_lines.append(values)
|
392
|
+
except:
|
393
|
+
pass
|
394
|
+
|
395
|
+
return {
|
396
|
+
"file_attributes": file_metadata,
|
397
|
+
"data_attributes": data_metadata,
|
398
|
+
"data": pd.DataFrame(data_lines, columns=columns)
|
399
|
+
}
|
@@ -4,13 +4,15 @@ from PIL import Image, ImageTk
|
|
4
4
|
import os
|
5
5
|
import platform
|
6
6
|
import subprocess
|
7
|
+
import shutil
|
8
|
+
|
9
|
+
from . import SideBar
|
7
10
|
|
8
11
|
def create_tab(self, tab):
|
9
12
|
|
10
13
|
def open_graph_in_browser():
|
11
14
|
# Open the file in the default program
|
12
|
-
|
13
|
-
folder = os.path.join(info['path'], info['name'])
|
15
|
+
folder = self.option_manager.get_project_folder()
|
14
16
|
|
15
17
|
if not os.path.exists(folder):
|
16
18
|
os.makedirs(folder)
|
@@ -23,7 +25,62 @@ def create_tab(self, tab):
|
|
23
25
|
subprocess.Popen(["open", file_path])
|
24
26
|
else:
|
25
27
|
subprocess.Popen(["xdg-open", file_path])
|
26
|
-
|
28
|
+
|
29
|
+
def export_graph():
|
30
|
+
|
31
|
+
folder = self.option_manager.get_project_folder()
|
32
|
+
|
33
|
+
if not os.path.exists(folder):
|
34
|
+
os.makedirs(folder)
|
35
|
+
|
36
|
+
html_file = os.path.join(folder, self.selected_graph_name + ".html")
|
37
|
+
json_file = os.path.join(folder, self.selected_graph_name + ".json")
|
38
|
+
png_file = os.path.join(folder, self.selected_graph_name + ".png")
|
39
|
+
pdf_file = os.path.join(folder, self.selected_graph_name + ".pdf")
|
40
|
+
|
41
|
+
# Make a directory call package
|
42
|
+
if not os.path.exists(os.path.join(folder, self.selected_graph_name + "_package")):
|
43
|
+
os.makedirs(os.path.join(folder, self.selected_graph_name + "_package"))
|
44
|
+
|
45
|
+
# Check if html_file exists and copy it to the package directory
|
46
|
+
if os.path.exists(html_file):
|
47
|
+
with open(html_file, 'r') as file:
|
48
|
+
data = file.read()
|
49
|
+
with open(os.path.join(folder, self.selected_graph_name + "_package", self.selected_graph_name + ".html"), 'w') as new_file:
|
50
|
+
new_file.write(data)
|
51
|
+
|
52
|
+
# Check if json_file exists and copy it to the package directory
|
53
|
+
if os.path.exists(json_file):
|
54
|
+
with open(json_file, 'r') as file:
|
55
|
+
data = file.read()
|
56
|
+
with open(os.path.join(folder, self.selected_graph_name + "_package", self.selected_graph_name + ".json"), 'w') as new_file:
|
57
|
+
new_file.write(data)
|
58
|
+
|
59
|
+
# Check if png_file exists and copy it to the package directory
|
60
|
+
if os.path.exists(png_file):
|
61
|
+
with open(png_file, 'rb') as file:
|
62
|
+
data = file.read()
|
63
|
+
with open(os.path.join(folder, self.selected_graph_name + "_package", self.selected_graph_name + ".png"), 'wb') as new_file:
|
64
|
+
new_file.write(data)
|
65
|
+
|
66
|
+
# Check if pdf_file exists and copy it to the package directory
|
67
|
+
if os.path.exists(pdf_file):
|
68
|
+
with open(pdf_file, 'rb') as file:
|
69
|
+
data = file.read()
|
70
|
+
with open(os.path.join(folder, self.selected_graph_name + "_package", self.selected_graph_name + ".pdf"), 'wb') as new_file:
|
71
|
+
new_file.write(data)
|
72
|
+
|
73
|
+
# Zip the package directory
|
74
|
+
shutil.make_archive(os.path.join(folder, self.selected_graph_name + "_package"), 'zip', os.path.join(folder, self.selected_graph_name + "_package"))
|
75
|
+
|
76
|
+
# Open the directory containing the package
|
77
|
+
if platform.system() == "Windows":
|
78
|
+
os.startfile(os.path.join(folder, self.selected_graph_name + "_package"))
|
79
|
+
elif platform.system() == "Darwin":
|
80
|
+
subprocess.Popen(["open", os.path.join(folder, self.selected_graph_name + "_package")])
|
81
|
+
else:
|
82
|
+
subprocess.Popen(["xdg-open", os.path.join(folder, self.selected_graph_name + "_package")])
|
83
|
+
|
27
84
|
def _resize_image(event):
|
28
85
|
self.graph_label.update_idletasks()
|
29
86
|
new_width = self.graph_label.winfo_width()
|
@@ -45,7 +102,7 @@ def create_tab(self, tab):
|
|
45
102
|
self.graph_label.update_idletasks()
|
46
103
|
|
47
104
|
|
48
|
-
tab.grid_columnconfigure(0, weight=
|
105
|
+
tab.grid_columnconfigure(0, weight=2)
|
49
106
|
tab.grid_columnconfigure(1, weight=8)
|
50
107
|
tab.grid_rowconfigure(0, weight=1)
|
51
108
|
|
@@ -55,22 +112,30 @@ def create_tab(self, tab):
|
|
55
112
|
self.graph_container.grid(row=0, column=1, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
56
113
|
|
57
114
|
self.graph_sidebar.grid_columnconfigure(0, weight=1)
|
58
|
-
self.graph_sidebar.grid_rowconfigure(
|
115
|
+
self.graph_sidebar.grid_rowconfigure(1, weight=1)
|
59
116
|
self.graph_container.grid_columnconfigure(0, weight=1)
|
60
117
|
self.graph_container.grid_rowconfigure(0, weight=1)
|
61
118
|
|
62
|
-
|
63
|
-
self.
|
64
|
-
self.graph_selector = customtkinter.CTkOptionMenu(self.graph_sidebar, values=["Best Cost Stacked", "Best Cost by Round", "Calibrated Parameters", "Iteration Table"], variable=self.graph_selector_value, command=self.update_graph)
|
119
|
+
graph_types = []
|
120
|
+
self.graph_selector = customtkinter.CTkOptionMenu(self.graph_sidebar, values=graph_types, variable=self.option_manager.get("selected_graph"), command=self.update_graph)
|
65
121
|
self.graph_selector.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
66
122
|
|
123
|
+
# Create SideBar
|
124
|
+
self.vis_sidebar = SideBar.SideBar(self.graph_sidebar, option_manager=self.option_manager, home_page=self, fg_color="transparent")
|
125
|
+
self.vis_sidebar.grid(row=1, column=0, rowspan=6, padx=(0, 0), pady=(0, 0), sticky="nsew")
|
126
|
+
|
127
|
+
|
128
|
+
self.graph_theme = customtkinter.CTkOptionMenu(self.graph_sidebar, values=["Dark", "Light", "Publication"], variable=self.option_manager.get("graph_theme"), command=self.update_graph)
|
129
|
+
self.graph_theme.grid(row=7, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
130
|
+
|
131
|
+
self.graph_export = customtkinter.CTkButton(self.graph_sidebar, text="Export", command=export_graph)
|
132
|
+
self.graph_export.grid(row=8, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
133
|
+
|
67
134
|
# Add a button to call open_graph_in_browser
|
68
|
-
self.graph_button = customtkinter.CTkButton(self.graph_sidebar, text="
|
135
|
+
self.graph_button = customtkinter.CTkButton(self.graph_sidebar, text="Preview", command=open_graph_in_browser)
|
69
136
|
self.graph_button.grid(row=9, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
70
137
|
|
71
138
|
self.graph_image_obj = Image.open(os.path.join("./images", "refresh_hd.png"))
|
72
139
|
self.graph_image = customtkinter.CTkImage(self.graph_image_obj, size=(1280, 720))
|
73
140
|
self.graph_label = customtkinter.CTkLabel(self.graph_container, text=None, image=self.graph_image)
|
74
141
|
self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
75
|
-
#window = customtkinter.CTk()
|
76
|
-
#self.graph_label.bind('<Configure>', _resize_image)
|
File without changes
|