CommentCollection class
CommentCollection class
Provides typed access to a collection of Comment nodes. To learn more, visit the Working with Comments documentation article.
Inheritance: CommentCollection → NodeCollection
Indexers
Name | Description |
---|---|
__getitem__(index) | Retrieves a Comment at the given index. |
Properties
Name | Description |
---|---|
count | Gets the number of nodes in the collection. (Inherited from NodeCollection) |
Methods
Name | Description |
---|---|
add(node) | Adds a node to the end of the collection. (Inherited from NodeCollection) |
clear() | Removes all nodes from this collection and from the document. (Inherited from NodeCollection) |
contains(node) | Determines whether a node is in the collection. (Inherited from NodeCollection) |
index_of(node) | Returns the zero-based index of the specified node. (Inherited from NodeCollection) |
insert(index, node) | Inserts a node into the collection at the specified index. (Inherited from NodeCollection) |
remove(node) | Removes the node from the collection and from the document. (Inherited from NodeCollection) |
remove_at(index) | Removes the node at the specified index from the collection and from the document. (Inherited from NodeCollection) |
to_array() | Copies all nodes from the collection to a new array of nodes. (Inherited from NodeCollection) |
Examples
Shows how to mark a comment as “done”.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
builder.writeln('Helo world!')
# Insert a comment to point out an error.
comment = aw.Comment(doc=doc, author='John Doe', initial='J.D.', date_time=datetime.datetime.now())
comment.set_text('Fix the spelling error!')
doc.first_section.body.first_paragraph.append_child(comment)
# Comments have a "Done" flag, which is set to "false" by default.
# If a comment suggests that we make a change within the document,
# we can apply the change, and then also set the "Done" flag afterwards to indicate the correction.
self.assertFalse(comment.done)
doc.first_section.body.first_paragraph.runs[0].text = 'Hello world!'
comment.done = True
# Comments that are "done" will differentiate themselves
# from ones that are not "done" with a faded text color.
comment = aw.Comment(doc=doc, author='John Doe', initial='J.D.', date_time=datetime.datetime.now())
comment.set_text('Add text to this paragraph.')
builder.current_paragraph.append_child(comment)
doc.save(file_name=ARTIFACTS_DIR + 'Comment.Done.docx')
See Also
- module aspose.words
- class NodeCollection