mg-pso-gui 0.2.75__tar.gz → 0.2.77__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/PKG-INFO +1 -1
  2. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mg_pso_gui.egg-info/PKG-INFO +1 -1
  3. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/HomePage.py +1 -1
  4. mg_pso_gui-0.2.77/mgpsogui/gui/VisualizeTab/SideBar.py +405 -0
  5. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/setup.py +1 -1
  6. mg_pso_gui-0.2.75/mgpsogui/gui/VisualizeTab/SideBar.py +0 -399
  7. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mg_pso_gui.egg-info/SOURCES.txt +0 -0
  8. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mg_pso_gui.egg-info/dependency_links.txt +0 -0
  9. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mg_pso_gui.egg-info/entry_points.txt +0 -0
  10. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mg_pso_gui.egg-info/requires.txt +0 -0
  11. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mg_pso_gui.egg-info/top_level.txt +0 -0
  12. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/__init__.py +0 -0
  13. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/General/ParameterView.py +0 -0
  14. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/General/__init__.py +0 -0
  15. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/OptionManager.py +0 -0
  16. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/OptionManager_backup.py +0 -0
  17. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/PlatformTab/PlatformTab.py +0 -0
  18. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/PlatformTab/__init__.py +0 -0
  19. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/RunTab/OptimalParameterView.py +0 -0
  20. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/RunTab/RunTab.py +0 -0
  21. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/RunTab/__init__.py +0 -0
  22. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/BoundsEditorWindow.py +0 -0
  23. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/BoundsList.py +0 -0
  24. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/CustomFunctionEditorWindow.py +0 -0
  25. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/CustomFunctionMetrics.py +0 -0
  26. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/FunctionsList.py +0 -0
  27. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/ListEditor.py +0 -0
  28. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/ListParametersView.py +0 -0
  29. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/OverrideParameterMetrics.py +0 -0
  30. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/OverrideParameterWindow.py +0 -0
  31. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/SetupTab.py +0 -0
  32. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/StepView.py +0 -0
  33. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/SetupTab/__init__.py +0 -0
  34. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/VisualizeTab/MatrixEditor.py +0 -0
  35. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/VisualizeTab/VisualizeTab.py +0 -0
  36. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/VisualizeTab/__init__.py +0 -0
  37. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/__init__.py +0 -0
  38. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/defaults/__init__.py +0 -0
  39. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/defaults/optimization.json +0 -0
  40. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/defaults/sampling.json +0 -0
  41. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/defaults/sensitivity.json +0 -0
  42. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/collapse.png +0 -0
  43. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/down.png +0 -0
  44. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/expand.png +0 -0
  45. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/play.png +0 -0
  46. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/plus.png +0 -0
  47. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/refresh.png +0 -0
  48. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/refresh_hd.png +0 -0
  49. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/stop.png +0 -0
  50. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/test.png +0 -0
  51. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/trash.png +0 -0
  52. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/gui/images/up.png +0 -0
  53. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/mgpsogui.py +0 -0
  54. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/start.yaml +0 -0
  55. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/CTkToolTip/__init__.py +0 -0
  56. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/CTkToolTip/ctk_tooltip.py +0 -0
  57. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/GraphGenerator.py +0 -0
  58. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/PSORunner.py +0 -0
  59. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/__init__.py +0 -0
  60. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/debug.py +0 -0
  61. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/helpers.py +0 -0
  62. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/__init__.py +0 -0
  63. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/pso/__init__.py +0 -0
  64. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/pso/csip_access.py +0 -0
  65. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/pso/pso.py +0 -0
  66. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/sampling/__init__.py +0 -0
  67. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/sampling/halton/__init__.py +0 -0
  68. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/sampling/halton/halton.py +0 -0
  69. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/sampling/halton/prime.py +0 -0
  70. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/sampling/random/__init__.py +0 -0
  71. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/sampling/random/random_sampler.py +0 -0
  72. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/sampling/sample_trace_writer.py +0 -0
  73. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/sampling/sampler_task.py +0 -0
  74. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/sampling/sampling.py +0 -0
  75. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/utils/__init__.py +0 -0
  76. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/utils/plot/__init__.py +0 -0
  77. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/utils/plot/cost_steps.py +0 -0
  78. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/utils/trace_writer.py +0 -0
  79. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/recosu/utils/utils.py +0 -0
  80. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/mgpsogui/util/sampler_test_driver.py +0 -0
  81. {mg_pso_gui-0.2.75 → mg_pso_gui-0.2.77}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mg-pso-gui
3
- Version: 0.2.75
3
+ Version: 0.2.77
4
4
  Summary: GUI for MG-PSO
5
5
  Author: Robert Cordingly
6
6
  Author-email: <rcording@uw.ed>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mg-pso-gui
3
- Version: 0.2.75
3
+ Version: 0.2.77
4
4
  Summary: GUI for MG-PSO
5
5
  Author: Robert Cordingly
6
6
  Author-email: <rcording@uw.ed>
@@ -251,7 +251,7 @@ class App(customtkinter.CTk):
251
251
  selected_graph = self.option_manager.get("selected_graph").get()
252
252
  if selected_graph not in graph_types:
253
253
  self.option_manager.get("selected_graph").set(graph_types[0])
254
-
254
+ self.graph_selector.configure(value=self.option_manager.get("selected_graph").get())
255
255
 
256
256
  if mode == "Optimization":
257
257
  self.test_button.configure(state="normal")
@@ -0,0 +1,405 @@
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
+ try:
43
+ self.option_manager.get("selected_graph").set("Best Cost Stacked")
44
+
45
+ selected_graph = self.option_manager.get("selected_graph").get()
46
+
47
+ if (selected_graph == "Best Cost Stacked"):
48
+ #self.graph_label = CTkLabel(self.containerFrame, text="Best Cost Stacked")
49
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
50
+ pass
51
+ elif (selected_graph == "Best Cost by Round"):
52
+ #self.graph_label = CTkLabel(self.containerFrame, text="Best Cost by Round")
53
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
54
+ pass
55
+ elif (selected_graph == "Iteration Table"):
56
+ #self.graph_label = CTkLabel(self.containerFrame, text="Iteration Table")
57
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
58
+ pass
59
+ elif (selected_graph == "Calibrated Parameters"):
60
+ #self.graph_label = CTkLabel(self.containerFrame, text="Calibrated Parameters")
61
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
62
+ pass
63
+ elif (selected_graph == "Custom CSV"):
64
+
65
+ folder = self.option_manager.get_project_folder()
66
+ if not os.path.exists(folder):
67
+ os.makedirs(folder)
68
+
69
+ # Get all CSV files in the folder and add their paths to a list
70
+ path_map = {}
71
+ name_list = []
72
+ for root, dirs, files in os.walk(folder):
73
+ for file in files:
74
+ if file.endswith(".csv"):
75
+ name = file.replace(".csv", "")
76
+ name_list.append(name)
77
+ path_map[name] = os.path.join(root, file)
78
+
79
+ if (len(name_list) == 0):
80
+ name_list.append("No files found...")
81
+ else:
82
+ if (self.option_manager.get("selected_csv").get() not in name_list):
83
+ self.option_manager.get("selected_csv").set(name_list[0])
84
+
85
+ file_label = CTkLabel(self.containerFrame, text="CSV File:")
86
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
87
+
88
+ 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)
89
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
90
+
91
+ selected_file = self.option_manager.get("selected_csv").get()
92
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
93
+ self.home_page.csv_data = self.load_special_csv(path_map[selected_file])
94
+ print(self.home_page.csv_data)
95
+ self.home_page.open_file = selected_file
96
+
97
+ if (self.home_page.csv_data is not None):
98
+ # Get all column names of CSV
99
+ columns = self.home_page.csv_data["data"].columns
100
+
101
+ x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
102
+ x_axis_label.grid(row=2, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
103
+
104
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
105
+ self.home_page.csv_x_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
106
+
107
+ if (self.home_page.csv_x_selector.get() not in columns):
108
+ self.home_page.csv_x_selector.set(columns[1])
109
+
110
+ y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
111
+ y1_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
112
+
113
+ self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
114
+ self.home_page.csv_y1_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
115
+
116
+ if (self.home_page.csv_y1_selector.get() not in columns):
117
+ self.home_page.csv_y1_selector.set(columns[2])
118
+
119
+ y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
120
+ y2_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
121
+
122
+ self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
123
+ self.home_page.csv_y2_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
124
+
125
+ if (self.home_page.csv_y2_selector.get() not in columns):
126
+ self.home_page.csv_y2_selector.set(columns[3])
127
+
128
+ elif (selected_graph == "Compare CSV"):
129
+ folder = self.option_manager.get_project_folder()
130
+ if not os.path.exists(folder):
131
+ os.makedirs(folder)
132
+
133
+ # Get all CSV files in the folder and add their paths to a list
134
+ path_map = {}
135
+ name_list = []
136
+ for root, dirs, files in os.walk(folder):
137
+ for file in files:
138
+ if file.endswith(".csv"):
139
+ name = file.replace(".csv", "")
140
+ name_list.append(name)
141
+ path_map[name] = os.path.join(root, file)
142
+
143
+ if (len(name_list) == 0):
144
+ name_list.append("No files found...")
145
+ else:
146
+ if (self.option_manager.get("selected_csv").get() not in name_list):
147
+ self.option_manager.get("selected_csv").set(name_list[0])
148
+ if (self.option_manager.get("selected_csv2").get() not in name_list):
149
+ self.option_manager.get("selected_csv2").set(name_list[0])
150
+
151
+ file_label = CTkLabel(self.containerFrame, text="CSV Files:")
152
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
153
+
154
+ 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)
155
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
156
+
157
+ 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)
158
+ self.home_page.csv_file_selector2.grid(row=2, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
159
+
160
+ selected_file = self.option_manager.get("selected_csv").get()
161
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
162
+ self.home_page.csv_data = self.load_special_csv(path_map[selected_file])
163
+ print(self.home_page.csv_data)
164
+ self.home_page.open_file = selected_file
165
+
166
+ selected_file2 = self.option_manager.get("selected_csv2").get()
167
+ if (selected_file2 in path_map and selected_file2 != self.home_page.open_file2):
168
+ self.home_page.csv_data2 = self.load_special_csv(path_map[selected_file2])
169
+ print(self.home_page.csv_data2)
170
+ self.home_page.open_file2 = selected_file2
171
+
172
+ if (self.home_page.csv_data is not None and self.home_page.csv_data2 is not None):
173
+ # Get all column names of CSV
174
+ columns = self.home_page.csv_data["data"].columns
175
+ columns2 = self.home_page.csv_data2["data"].columns
176
+
177
+ x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
178
+ x_axis_label.grid(row=3, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
179
+
180
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
181
+ self.home_page.csv_x_selector.grid(row=4, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
182
+
183
+ if (self.home_page.csv_x_selector.get() not in columns):
184
+ self.home_page.csv_x_selector.set(columns[1])
185
+
186
+ y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
187
+ y1_axis_label.grid(row=5, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
188
+
189
+ self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
190
+ self.home_page.csv_y1_selector.grid(row=6, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
191
+
192
+ if (self.home_page.csv_y1_selector.get() not in columns):
193
+ self.home_page.csv_y1_selector.set(columns[2])
194
+
195
+ y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
196
+ y2_axis_label.grid(row=7, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
197
+
198
+ self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns2, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
199
+ self.home_page.csv_y2_selector.grid(row=8, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
200
+
201
+ if (self.home_page.csv_y2_selector.get() not in columns2):
202
+ self.home_page.csv_y2_selector.set(columns2[2])
203
+
204
+ elif (selected_graph == "Sampling CSV"):
205
+
206
+ folder = self.option_manager.get_project_folder()
207
+ if not os.path.exists(folder):
208
+ os.makedirs(folder)
209
+
210
+ # Get all CSV files in the folder and add their paths to a list
211
+ path_map = {}
212
+ name_list = []
213
+ for root, dirs, files in os.walk(folder):
214
+ for file in files:
215
+ if file.endswith(".csv"):
216
+ name = file.replace(".csv", "")
217
+ name_list.append(name)
218
+ path_map[name] = os.path.join(root, file)
219
+
220
+ if (len(name_list) == 0):
221
+ name_list.append("No files found...")
222
+ else:
223
+ if (self.option_manager.get("selected_csv").get() not in name_list):
224
+ self.option_manager.get("selected_csv").set(name_list[0])
225
+
226
+ file_label = CTkLabel(self.containerFrame, text="CSV File:")
227
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
228
+
229
+ 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)
230
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
231
+
232
+ selected_file = self.option_manager.get("selected_csv").get()
233
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
234
+ self.home_page.csv_data = pd.read_csv(path_map[selected_file])
235
+ print(self.home_page.csv_data)
236
+ self.home_page.open_file = selected_file
237
+
238
+ if (self.home_page.csv_data is not None):
239
+ # Get all column names of CSV
240
+ columns = self.home_page.csv_data.columns
241
+
242
+ x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
243
+ x_axis_label.grid(row=2, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
244
+
245
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
246
+ self.home_page.csv_x_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
247
+
248
+ if (self.home_page.csv_x_selector.get() not in columns):
249
+ self.home_page.csv_x_selector.set(columns[1])
250
+
251
+ y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
252
+ y1_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
253
+
254
+ self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
255
+ self.home_page.csv_y1_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
256
+
257
+ if (self.home_page.csv_y1_selector.get() not in columns):
258
+ self.home_page.csv_y1_selector.set(columns[2])
259
+
260
+ y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
261
+ y2_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
262
+
263
+ self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
264
+ self.home_page.csv_y2_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
265
+
266
+ if (self.home_page.csv_y2_selector.get() not in columns):
267
+ self.home_page.csv_y2_selector.set(columns[3])
268
+
269
+ style_label = CTkLabel(self.containerFrame, text="Figure Style:")
270
+ style_label.grid(row=8, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
271
+
272
+ 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)
273
+ self.home_page.figure_style_selector.grid(row=9, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
274
+
275
+ elif (selected_graph == "Matrix Editor"):
276
+
277
+ folder = self.option_manager.get_project_folder()
278
+ if not os.path.exists(folder):
279
+ os.makedirs(folder)
280
+
281
+ # Get all CSV files in the folder and add their paths to a list
282
+ path_map = {}
283
+ name_list = []
284
+ for root, dirs, files in os.walk(folder):
285
+ for file in files:
286
+ if file.endswith(".csv"):
287
+ name = file.replace(".csv", "")
288
+ name_list.append(name)
289
+ path_map[name] = os.path.join(root, file)
290
+
291
+ if (len(name_list) == 0):
292
+ name_list.append("No files found...")
293
+ else:
294
+ if (self.option_manager.get("selected_csv").get() not in name_list):
295
+ self.option_manager.get("selected_csv").set(name_list[0])
296
+
297
+ file_label = CTkLabel(self.containerFrame, text="CSV File:")
298
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
299
+
300
+ 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)
301
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
302
+
303
+ selected_file = self.option_manager.get("selected_csv").get()
304
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
305
+ self.home_page.csv_data = pd.read_csv(path_map[selected_file])
306
+ print(self.home_page.csv_data)
307
+ self.home_page.open_file = selected_file
308
+
309
+ if (self.home_page.csv_data is not None):
310
+ # Get all column names of CSV
311
+ columns = self.home_page.csv_data.columns
312
+
313
+ style_label = CTkLabel(self.containerFrame, text="Figure Style:")
314
+ style_label.grid(row=2, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
315
+
316
+ 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)
317
+ self.home_page.figure_style_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
318
+
319
+ x_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
320
+ x_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
321
+
322
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
323
+ self.home_page.csv_x_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
324
+
325
+ if (self.home_page.csv_x_selector.get() not in columns):
326
+ self.home_page.csv_x_selector.set(columns[1])
327
+
328
+ self.matrix_editor = me.MatrixEditor(self.containerFrame, width=280, option_manager=self.option_manager, home_page=self.home_page, columns=columns)
329
+ self.matrix_editor.grid(row=6, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
330
+ self.matrix_editor.grid_columnconfigure(0, weight=1)
331
+ self.matrix_editor.grid_rowconfigure(0, weight=1)
332
+
333
+
334
+ #y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
335
+ #y1_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
336
+
337
+ #self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
338
+ #self.home_page.csv_y1_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
339
+
340
+ #if (self.home_page.csv_y1_selector.get() not in columns):
341
+ # self.home_page.csv_y1_selector.set(columns[2])
342
+ except Exception as e:
343
+ print(e)
344
+ pass
345
+
346
+ def load_special_csv(self, file_path):
347
+ file_metadata = {}
348
+ data_metadata = {}
349
+ mode = "file_metadata"
350
+ columns = []
351
+ data_lines = []
352
+
353
+ with open(file_path, "r") as file:
354
+ lines = file.readlines()
355
+
356
+ if (not lines[0].startswith("@")):
357
+ return {
358
+ "file_attributes": {},
359
+ "data_attributes": {},
360
+ "data": pd.read_csv(file_path)
361
+ }
362
+
363
+ for line in lines:
364
+ if (line.startswith("@H,")):
365
+ mode = "data_metadata"
366
+ columns = line.strip().rstrip(",").split(",")[1:]
367
+ continue
368
+ elif (line.startswith("@T,")):
369
+ mode = "file_metadata"
370
+ continue
371
+ elif (line.startswith(",") and mode == "data_metadata"):
372
+ mode = "file_data"
373
+
374
+ if (mode == "file_metadata"):
375
+ try:
376
+ key, value = line.strip().rstrip(",").split(",")
377
+ file_metadata[key] = value
378
+ except:
379
+ pass
380
+
381
+ elif (mode == "data_metadata"):
382
+ try:
383
+ values = line.strip().rstrip(",").split(",")
384
+ key = values[0]
385
+ values = values[1:]
386
+ if len(values) == len(columns):
387
+ data_metadata[key] = {}
388
+ for i in range(len(columns)):
389
+ data_metadata[key][columns[i]] = values[i]
390
+ except:
391
+ pass
392
+
393
+ elif (mode == "file_data"):
394
+ try:
395
+ values = line.strip().rstrip(",").split(",")[1:]
396
+ if len(values) == len(columns):
397
+ data_lines.append(values)
398
+ except:
399
+ pass
400
+
401
+ return {
402
+ "file_attributes": file_metadata,
403
+ "data_attributes": data_metadata,
404
+ "data": pd.DataFrame(data_lines, columns=columns)
405
+ }
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
  import codecs
3
3
  import os
4
4
 
5
- VERSION = '0.2.75'
5
+ VERSION = '0.2.77'
6
6
  DESCRIPTION = 'GUI for MG-PSO'
7
7
  LONG_DESCRIPTION = open('../README.md').read()
8
8
 
@@ -1,399 +0,0 @@
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
- }
File without changes