Skip to content

hkb_editor.hkb.xml

HkbXmlElement

Bases: ElementBase

Custom lxml Element that tracks mutations for undo/redo.

attrib property

attrib

Incurs slight overhead as it wraps the actual element's attrib dict in a class that tracks mutations. Consider using get and set instead. It is discouraged to keep references to the returned dict. Accessing the same dict instance before and after an undo/redo operation may result in undefined behavior.

UndoAttrib

Bases: dict

Wrapper around element.attrib that tracks mutations.

UndoStack

transaction

transaction()

Group multiple mutations into a single undo/redo action.

Usage: with undo_stack.transaction(): element.set("a", "1") element.set("b", "2") element.append(child) # All three operations undo/redo together