Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions waveform_editor/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@


class Annotations(UserList):
def __str__(self):
sorted_annotations = sorted(self, key=lambda ann: ann["row"])
return "\n".join(
f"Line {a['row'] + 1}: {a['text']}" for a in sorted_annotations
)

def add_annotations(self, annotations):
"""Merge another Annotations instance into this instance by appending its
annotations.
Expand Down
11 changes: 8 additions & 3 deletions waveform_editor/waveform_editor_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
yaml_parser = YamlParser()

yaml_alert = pn.pane.Alert(
"### The YAML did not parse correctly! (see editor)",
"### The YAML did not parse correctly!",
alert_type="danger",
visible=False,
)
error_alert = pn.pane.Alert(
"### There was an error in the YAML configuration (see editor).",
"### There was an error in the YAML configuration.",
alert_type="warning",
visible=False,
)
Expand All @@ -41,14 +41,19 @@
def update_plot(value):
yaml_alert.visible = error_alert.visible = False
yaml_parser.parse_waveforms(value)
annotations = yaml_parser.waveform.annotations

code_editor.annotations = list(yaml_parser.waveform.annotations)
code_editor.annotations = list(annotations)
code_editor.param.trigger("annotations")

# Show alert when there is a yaml parsing error
if yaml_parser.has_yaml_error:
yaml_alert.object = f"### The YAML did not parse correctly\n {annotations}"
yaml_alert.visible = True
elif code_editor.annotations:
error_alert.object = (
f"### There was an error in the YAML configuration\n {annotations}"
)
error_alert.visible = True
return yaml_parser.plot_tendencies()

Expand Down