Skip to content

Commit 9a7a06b

Browse files
committed
add error message to alert
1 parent 7139bb7 commit 9a7a06b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

waveform_editor/annotations.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44

55
class Annotations(UserList):
6+
def __str__(self):
7+
sorted_annotations = sorted(self, key=lambda ann: ann["row"])
8+
return "\n".join(
9+
f"line {ann['row']}: {ann['text']}" for ann in sorted_annotations
10+
)
11+
612
def add_annotations(self, annotations):
713
"""Merge another Annotations instance into this instance by appending its
814
annotations.

waveform_editor/waveform_editor_gui.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
yaml_parser = YamlParser()
2828

2929
yaml_alert = pn.pane.Alert(
30-
"### The YAML did not parse correctly! (see editor)",
30+
"### The YAML did not parse correctly!",
3131
alert_type="danger",
3232
visible=False,
3333
)
3434
error_alert = pn.pane.Alert(
35-
"### There was an error in the YAML configuration (see editor).",
35+
"### There was an error in the YAML configuration.",
3636
alert_type="warning",
3737
visible=False,
3838
)
@@ -41,14 +41,19 @@
4141
def update_plot(value):
4242
yaml_alert.visible = error_alert.visible = False
4343
yaml_parser.parse_waveforms(value)
44+
annotations = yaml_parser.waveform.annotations
4445

45-
code_editor.annotations = list(yaml_parser.waveform.annotations)
46+
code_editor.annotations = list(annotations)
4647
code_editor.param.trigger("annotations")
4748

4849
# Show alert when there is a yaml parsing error
4950
if yaml_parser.has_yaml_error:
51+
yaml_alert.bject = (f"### The YAML did not parse correctly!\n {bleep}",)
5052
yaml_alert.visible = True
5153
elif code_editor.annotations:
54+
error_alert.object = (
55+
f"### There was an error in the YAML configuration.\n {annotations}"
56+
)
5257
error_alert.visible = True
5358
return yaml_parser.plot_tendencies()
5459

0 commit comments

Comments
 (0)