NoteTag — Aspose.Note FOSS for Python API Reference

Lớp: NoteTag

Enumerations: aspose.note Enumerations: from aspose.note import NoteTag Enumerations: Node

NoteTag đại diện cho một biểu tượng thẻ OneNote (ngôi sao, hộp kiểm, dấu quan trọng, v.v.) được gắn vào một nút nội dung. Các thẻ xuất hiện trên RichText, Image, AttachedFile, OutlineElement, và Table các nút thông qua .Tags thuộc tính.


Enumerations

Tất cả các thuộc tính đều chỉ đọc và phản ánh các giá trị được phân tích trực tiếp từ định dạng nhị phân MS-ONE.

EnumerationsEnumerationsEnumerationsEnumerations
shape`intNone`None
label`strNone`None
text_color`intNone`None
highlight_color`intNone`None
created`intNone`None
completed`intNone`None

Kế thừa từ Node

EnumerationsEnumerationsEnumerations
ParentNode`NodeNone`
Document`DocumentNone`

Ghi chú thời gian

createdcompleted là các dấu thời gian nguyên số thô được phân tích từ định dạng nhị phân MS-ONE. Chúng là không datetime đối tượng. Nếu bạn cần làm việc với chúng dưới dạng ngày giờ Python, hãy tham khảo đặc tả định dạng tệp MS-ONE để biết công thức chuyển đổi.


Phương thức tạo

NoteTag.CreateYellowStar()

tag = NoteTag.CreateYellowStar() -> NoteTag

Trả về một đối tượng mới NoteTag với shape=Nonelabel="Yellow Star". Hữu ích khi xây dựng tài liệu một cách lập trình.


Ví dụ sử dụng

Liệt kê tất cả các phần tử có thẻ trong tài liệu

from aspose.note import Document, RichText, Image, AttachedFile, OutlineElement

doc = Document("MyNotes.one")

# Tags on RichText
for rt in doc.GetChildNodes(RichText):
    for tag in rt.Tags:
        print(f"RichText tag: label={tag.label!r}  on: {rt.Text.strip()[:40]!r}")

# Tags on Images
for img in doc.GetChildNodes(Image):
    for tag in img.Tags:
        print(f"Image tag: label={tag.label!r}  file={img.FileName!r}")

# Tags on AttachedFiles
for af in doc.GetChildNodes(AttachedFile):
    for tag in af.Tags:
        print(f"Attachment tag: label={tag.label!r}  file={af.FileName!r}")

Lọc các thẻ “To Do” chưa hoàn thành

from aspose.note import Document, RichText

doc = Document("MyNotes.one")
for rt in doc.GetChildNodes(RichText):
    for tag in rt.Tags:
        if tag.label and "to do" in tag.label.lower() and tag.completed is None:
            print(f"Incomplete TODO: {rt.Text.strip()!r}")

None-Safety

label, shape, text_color, highlight_color, created, và completed có thể đều là None. Hãy kiểm tra trước khi sử dụng. Tags danh sách trên các nút nội dung luôn là danh sách (không bao giờ None), nhưng có thể rỗng.


Xem Thêm

 Tiếng Việt