@@ -198,6 +198,10 @@ def __init__(self, parent: "Microscope") -> None:
198198 self .use_epics_pv : bool = False
199199 self .epics_pv_name : str = ""
200200 self .epics_pv : "PV|None" = None
201+ self .start_record_action = QAction ("Start Record" , self .parent ())
202+ self .start_record_action .triggered .connect (lambda : self ._set_record (True ))
203+ self .stop_record_action = QAction ("Stop Record" , self .parent ())
204+ self .stop_record_action .triggered .connect (lambda : self ._set_record (False ))
201205
202206 def qimage_to_mat (self , qimage : QImage ):
203207 qimage = qimage .convertToFormat (QImage .Format .Format_ARGB32 )
@@ -271,9 +275,8 @@ def context_menu_entry(self):
271275 actions .append (self .record_action )
272276 return actions
273277
274- def _record (self ):
275- self .recording = not self .recording
276- if self .recording :
278+ def _set_record (self , start ):
279+ if start :
277280 print ("Starting record in _record" )
278281 self .start_time = datetime .now ()
279282 self .current_filepath = Path (self .filename .parent ) / Path (
@@ -302,6 +305,10 @@ def _record(self):
302305 )
303306 self ._update_files ()
304307
308+ def _record (self ):
309+ self .recording = not self .recording
310+ self ._set_record (self .recording )
311+
305312 def _update_files (self ):
306313 """Function to check if number of files in the destination folder is correct
307314 Otherwise delete oldest file(s)
@@ -322,10 +329,10 @@ def _start_epics_record(self, **kwargs):
322329 if kwargs ["pvname" ] == self .epics_pv_name :
323330 if kwargs ["value" ] == 1 and not self .recording :
324331 print (f"{ self .epics_pv_name } : { kwargs ['value' ]} . START record action" )
325- self .record_action .trigger ()
332+ self .start_record_action .trigger ()
326333 elif kwargs ["value" ] == 0 and self .recording :
327334 print (f"{ self .epics_pv_name } : { kwargs ['value' ]} . STOP record action" )
328- self .record_action .trigger ()
335+ self .stop_record_action .trigger ()
329336
330337 def read_settings (self , settings : Dict [str , Any ]):
331338 self .fps = int (settings .get ("fps" , 5 ))
0 commit comments