kivy-garden / garden.matplotlib

Matplotlib backends using kivy
MIT License
103 stars 50 forks source link

close_event added #21

Closed andnovar closed 9 years ago

andnovar commented 9 years ago

I came across that close_event is missed in backend_kivy, but I need the widget to be notified when this happens in order to trigger the close_event.

Example:

https://gist.github.com/andnovar/dd85b6e0a17ba045f511

When the button is pressed I remove the widget from the floatlayout and the close_event is triggered. However I need to set a property in the Widget class to notify the figure canvas which is opened in this pr:

https://github.com/kivy/kivy/pull/3620

matham commented 9 years ago

That won't work in all cases because just because the parent was removed doesn't mean it has closed. For starters, what if its parent's parent never had a parent so it was not visible to begin with? I don't think relying on parent is a reliable way of triggering the close event.

Similarly, what if the app closes, will this event never fire? So I think we need to leave this to the user to decide when a figure has closed. I think the only solution is to document this in the docs that if the close event is to be used, close_event must be called manually when the figure is considered to have been closed, either by removing it from screen or by closing the app.

andnovar commented 9 years ago

Alright makes sense. I'll open another pr with your suggested solution.