Replymessage unavailable
First, please paste the code at pastebin.com or something like that and provide a link. This will save the formatting. But more importantly, the chat is bridged to an IRC. There, every line is a message, making it painstaking to collect the code to execute.
Second, the code is far from an MWE, with lots of non-essential items. There is no entry point, there is no new_window. I suspect that deleting the widget manually might not be necessary in Python, but I'm too lazy to make the test up.