I wants to build some GUI for retrieving and displaying some data in real time. So I though of embedding a matplotlib figure in a pyqt5 GUI, and followed this example here (https://matplotlib.org/examples/user_interfaces/embedding_in_qt5.html). However, there will be some resource for my application that require a safe destruction at exit. So I tried to overwrite the closeEvent() function of MyMplCanvas with
def closeEvent(self,ce):
print('closeEvent')
super().closeEvent(ce)
But it does not seem to show up when I run the program. Is this expected or is there anything wrong with the program? If this is not the proper way to do so, what is the right way to do some clean-up during the destruction of a QWidget? Thanks a lot!