Python event handling

@clement It’s been a while, sorry about the very late reply and thank you alot for your helpful answer! I took your advise on setting a global flag and have atleast started considering undos, new and closed documents etc. There are probably a bunch of things to improve still, but atleast it seems …