99 QCheckBox ,
1010)
1111
12- from ephys .classes .experiment_objects import ExpData
12+ from ephys .classes .experiment_objects import ExpData , MetaData
1313from ephys .GUI .sessioninfo import SessionInfo
1414from ephys .GUI .sidemenu import SideMenu , SideMenuContainer
1515from ephys .GUI .sidebar_right import SideBarRight
@@ -26,7 +26,6 @@ def __init__(self):
2626 self .session_info = SessionInfo ()
2727
2828 self .threadpool = QThreadPool ()
29- self .highlight = False
3029 thread_count = self .threadpool .maxThreadCount ()
3130 print (f"Multithreading enabled with { thread_count } threads." )
3231
@@ -56,7 +55,7 @@ def __init__(self):
5655 self .sweep_selector .setSingleStep (1 )
5756
5857 self .highlight_switch = QCheckBox ("Highlight" )
59- self .highlight_switch .setChecked (self . highlight )
58+ self .highlight_switch .setChecked (False )
6059 self .highlight_switch .stateChanged .connect (self .change_highlight )
6160 self .status_bar .addPermanentWidget (self .highlight_switch )
6261
@@ -83,9 +82,12 @@ def __init__(self):
8382 )
8483 # splitter.addWidget(sidebar_frame)
8584 # Create a layout for the frame
86- menu_layout_left = SideMenu (self )
85+ self .menu_layout_left = SideMenu (self )
86+ self .menu_layout_left .combobox .currentTextChanged .connect (
87+ self .select_file_from_list
88+ )
8789
88- sidebar_frame .setLayout (menu_layout_left )
90+ sidebar_frame .setLayout (self . menu_layout_left )
8991
9092 splitter .addWidget (sidebar_frame )
9193 # splitter.addWidget(menu_layout_left)
@@ -105,7 +107,7 @@ def __init__(self):
105107 sidebar_right .setMaximumSize (QSize (300 , 1200 ))
106108 splitter .addWidget (sidebar_right )
107109
108- menu_layout_left .addWidget (self .side_menu_container )
110+ self . menu_layout_left .addWidget (self .side_menu_container )
109111 # Add the session info widget
110112
111113 # decouple tab_widget from the splitter
@@ -114,6 +116,9 @@ def __init__(self):
114116
115117 def closeEvent (self , event ) -> None :
116118 print ("Window closed" )
119+ # Perform any necessary cleanup here
120+ if isinstance (self .data , ExpData ):
121+ self .data = None
117122 event .accept ()
118123
119124 def close_tab (self , index : int ) -> None :
@@ -124,14 +129,17 @@ def close_tab(self, index: int) -> None:
124129
125130 # Disconnect the tabCloseRequested signal temporarily to prevent cascading closes
126131 old_signal = self .trace_plot .tabCloseRequested .disconnect ()
127-
132+ if isinstance (self .data , ExpData ):
133+ self .data .remove_file (index = index )
134+ self .session_info .set_file_path (self .data .meta_data .get_file_path ())
135+ self .session_info .set_file_list (self .data .meta_data .get_file_name ())
128136 # Remove just this one tab
129137 self .trace_plot .removeTab (index )
130138 print (f"Closed tab '{ tab_title } ' at index { index } " )
131139
132140 # Reconnect the signal
133141 self .trace_plot .tabCloseRequested .connect (self .close_tab )
134-
142+ self . menu_layout_left . refresh_file_list ()
135143 # Clean up the tab's resources safely
136144 if isinstance (tab_selected , TracePlotWindow ):
137145 try :
@@ -149,12 +157,9 @@ def on_color_selected(self, color) -> None:
149157 def _sweep_highlight (self , sweep_number : int | None ) -> None :
150158 """Highlight a specific sweep in the plot."""
151159 current_tab_index = self .trace_plot .currentIndex ()
152- print (current_tab_index )
153160 current_trace_tab = self .trace_plot .widget (0 )
154161 sweep_index = None
155162 if isinstance (current_trace_tab , TracePlotWindow ):
156- print (current_trace_tab .trace_list )
157- print (len (current_trace_tab .trace_list ))
158163 current_plot = current_trace_tab .trace_list [current_tab_index ]
159164 if sweep_number is None :
160165 sweep_index = None
@@ -170,21 +175,30 @@ def sweep_highlight(self, sweep_number: int | None = None) -> None:
170175
171176 def connect_sweep_selector (self ) -> None :
172177 current_tab_index : int = self .trace_plot .currentIndex ()
173- print (current_tab_index )
174- self .sweep_selector .setRange (
175- 1 , self .trace_list [current_tab_index ].trace .sweep_count
176- )
177- print (self .trace_list [current_tab_index ].trace .sweep_count )
178- self .sweep_selector .setValue (
179- self .trace_list [current_tab_index ].highlight ["sweep_index" ]
180- )
178+ if current_tab_index >= 0 and len (self .trace_list ) > 0 :
179+ if self .trace_list [current_tab_index ].trace .sweep_count == 1 :
180+ self .sweep_selector .setEnabled (False )
181+ else :
182+ self .sweep_selector .setEnabled (True )
183+ self .sweep_selector .setRange (
184+ 1 , self .trace_list [current_tab_index ].trace .sweep_count
185+ )
186+ if self .trace_list [current_tab_index ].highlight ["sweep_index" ] is None :
187+ self .sweep_selector .setValue (1 )
188+ else :
189+ self .sweep_selector .setValue (
190+ self .trace_list [current_tab_index ].highlight ["sweep_index" ]
191+ )
181192
182193 def change_highlight (self ) -> None :
183194 if not self .highlight_switch .isChecked ():
184195 self .sweep_highlight (sweep_number = None )
185196 else :
186197 self .sweep_highlight (sweep_number = self .sweep_selector .value ())
187198
199+ def select_file_from_list (self , s ):
200+ print ("text change: " , s )
201+
188202 # def close_tab(self, index: int) -> None:
189203 # """Close the tab at the given index."""
190204 # tab_selected: TracePlotWindow = cast(
@@ -219,4 +233,4 @@ def change_highlight(self) -> None:
219233 # self.the_button_was_clicked(file_path)
220234 # if isinstance(file_path, str):
221235 # file_path = [file_path]
222- # self.file_list = file_path
236+ # self.file_list = file_pathlen(self.trace_list)
0 commit comments