@@ -61,17 +61,19 @@ def select_and_notify_split(self, split_unit_id):
6161 ## Qt
6262 def _qt_make_layout (self ):
6363 from .myqt import QT
64- import pyqtgraph as pg
6564
6665 self .merge_info = {}
6766 self .layout = QT .QVBoxLayout ()
6867
6968 tb = self .qt_widget .view_toolbar
70- if self .controller .curation_can_be_saved ():
69+ if self .controller .curation_callback is not None :
70+ but = QT .QPushButton ("Save curation" )
71+ tb .addWidget (but )
72+ but .clicked .connect (self .controller .save_curation_callback )
73+ elif self .controller .curation_can_be_saved ():
7174 but = QT .QPushButton ("Save in analyzer" )
7275 tb .addWidget (but )
73- but .clicked .connect (self .save_in_analyzer )
74-
76+ but .clicked .connect (self .controller .save_curation_in_analyzer )
7577 but = QT .QPushButton ("Export JSON" )
7678 but .clicked .connect (self ._qt_export_json )
7779 tb .addWidget (but )
@@ -275,9 +277,6 @@ def _qt_on_unit_visibility_changed(self):
275277 def on_manual_curation_updated (self ):
276278 self .refresh ()
277279
278- def save_in_analyzer (self ):
279- self .controller .save_curation_in_analyzer ()
280-
281280 def _qt_export_json (self ):
282281 from .myqt import QT
283282
@@ -351,37 +350,47 @@ def _panel_make_layout(self):
351350 )
352351
353352 # Create buttons
354- buttons_row = []
355- self .save_button = None
356- if self .controller .curation_can_be_saved ():
357- self .save_button = pn .widgets .Button (name = "Save in analyzer" , button_type = "primary" , height = 30 )
358- self .save_button .on_click (self ._panel_save_in_analyzer )
359- buttons_row .append (self .save_button )
360-
361- self .download_button = pn .widgets .FileDownload (
353+ if self .controller .curation_callback is not None :
354+ save_button_name = "Save curation"
355+ save_button_callback = self ._panel_save_curation_callback
356+ else :
357+ save_button_name = "Save in analyzer"
358+ save_button_callback = self ._panel_save_in_analyzer
359+ save_button = pn .widgets .Button (
360+ name = save_button_name ,
361+ button_type = "primary" ,
362+ height = 30
363+ )
364+ save_button .on_click (save_button_callback )
365+
366+ download_button = pn .widgets .FileDownload (
362367 button_type = "primary" , filename = "curation.json" , callback = self ._panel_generate_json , height = 30
363368 )
364- buttons_row .append (self .download_button )
365369
366370 restore_button = pn .widgets .Button (name = "Restore" , button_type = "primary" , height = 30 )
367371 restore_button .on_click (self ._panel_restore_units )
368372
369373 remove_merge_button = pn .widgets .Button (name = "Unmerge" , button_type = "primary" , height = 30 )
370374 remove_merge_button .on_click (self ._panel_unmerge )
371375
372- remove_split = pn .widgets .Button (name = "Unsplit" , button_type = "primary" , height = 30 )
373- remove_split .on_click (self ._panel_unsplit )
376+ remove_split_button = pn .widgets .Button (name = "Unsplit" , button_type = "primary" , height = 30 )
377+ remove_split_button .on_click (self ._panel_unsplit )
374378
375379 # Create layout
376- self .buttons_save = pn .Row (
377- * buttons_row ,
380+ buttons_save = pn .Row (
381+ save_button ,
382+ download_button ,
383+ sizing_mode = "stretch_width" ,
384+ )
385+ save_sections = pn .Column (
386+ buttons_save ,
378387 sizing_mode = "stretch_width" ,
379388 )
380389
381390 buttons_curate = pn .Row (
382391 restore_button ,
383392 remove_merge_button ,
384- remove_split ,
393+ remove_split_button ,
385394 sizing_mode = "stretch_width" ,
386395 )
387396
@@ -397,7 +406,7 @@ def _panel_make_layout(self):
397406 # Create main layout with proper sizing
398407 sections = pn .Row (self .table_delete , self .table_merge , self .table_split , sizing_mode = "stretch_width" )
399408 self .layout = pn .Column (
400- self . buttons_save , buttons_curate , sections , shortcuts_component , scroll = True , sizing_mode = "stretch_both"
409+ save_sections , buttons_curate , sections , shortcuts_component , scroll = True , sizing_mode = "stretch_both"
401410 )
402411
403412 def _panel_refresh (self ):
@@ -447,7 +456,7 @@ def _panel_ensure_save_warning_message(self):
447456 import panel as pn
448457
449458 alert_markdown = pn .pane .Markdown (
450- f"""⚠️⚠️⚠️ Your curation is not saved""" ,
459+ f"""⚠️ Your curation is not saved! """ ,
451460 hard_line_break = True ,
452461 styles = {"color" : "red" , "font-size" : "16px" },
453462 name = "curation_save_warning" ,
@@ -490,7 +499,11 @@ def _panel_unsplit(self, event):
490499 self .unsplit ()
491500
492501 def _panel_save_in_analyzer (self , event ):
493- self .save_in_analyzer ()
502+ self .controller .save_curation_in_analyzer ()
503+ self .refresh ()
504+
505+ def _panel_save_curation_callback (self , event ):
506+ self .controller .save_curation_callback ()
494507 self .refresh ()
495508
496509 def _panel_generate_json (self ):
@@ -612,12 +625,12 @@ def _conditional_refresh_split(self):
612625revert, and export the curation data.
613626
614627### Controls
615- - **save in analyzer**: Save the current curation state in the analyzer.
628+ - **save in analyzer**/**save data**: Save the current curation state in the analyzer.
629+ If a custom save callback is provided, it will be used instead.
616630- **export/download JSON**: Export the current curation state to a JSON file.
617631- **restore**: Restore the selected unit from the deleted units table.
618632- **unmerge**: Unmerge the selected merges from the merged units table.
619633- **unsplit**: Unsplit the selected split groups from the split units table.
620- - **submit to parent**: Submit the current curation state to the parent window (for use in web applications).
621634- **press 'ctrl+r'**: Restore the selected units from the deleted units table.
622635- **press 'ctrl+u'**: Unmerge the selected merges from the merged units table.
623636- **press 'ctrl+x'**: Unsplit the selected split groups from the split units table.
0 commit comments