-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock_events.py
More file actions
33 lines (21 loc) · 854 Bytes
/
Copy pathblock_events.py
File metadata and controls
33 lines (21 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Custom event types for block-related operations."""
from __future__ import annotations
from typing import List, NamedTuple
from PyQt6.QtCore import QEvent
from rhyme import RhymeMark
class RhymeSyllableResult(NamedTuple):
"""Holds the result of a rhyme and syllable analysis."""
syllable_counts: List[int]
rhyme_marks: List[RhymeMark | None]
class AnalysisResultEvent(QEvent):
"""Event carrying the results of a block analysis."""
EVENT_TYPE = QEvent.Type(QEvent.Type.User + 1)
def __init__(self, block_id: str, result: RhymeSyllableResult) -> None:
"""Initialize the event.
Args:
block_id: The ID of the block that was analyzed.
result: The analysis result.
"""
super().__init__(self.EVENT_TYPE)
self.block_id = block_id
self.result = result