0

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!

hz lin
  • 1
  • 1
  • be sure to override the widget you are closing like in [this post](https://stackoverflow.com/questions/34680103/how-to-detect-dialogs-close-event) – PRMoureu Jul 07 '17 at 18:41
  • I did override the widget in the main GUI, not the main GUI. I kind of work around it by calling something like chileWidget.close() in the closeEvent() for my parent (main) widget. However I am not sure if this is the right way to do it. – hz lin Jul 08 '17 at 18:49

0 Answers0