Trackchange Record Mode

I need a Python macro to toggle track changes mode recording. I made the VBA code with a macro recorder but I can not convert it to Python. I would appreciate any help or guidance.

sub Main
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(“com.sun.star.frame.DispatchHelper”)

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = “TrackChanges”
args1(0).Value = true

dispatcher.executeDispatch(document, “.uno:TrackChanges”, “”, 0, args1())
end sub