made idle_event() in backend_bases.py return True#3769
Conversation
|
What impact will this have on other backends? |
|
I tested gtk, qt, tk and wx and they all work fine with the change. From grepping for 'idle_event' and some testing, it appears that the gtk and wx backends are the only ones that call idle_event, and gtk/gtk3 is the only one that uses the function as a callback (wx calls it directly from its own callback). So I am fairly certain only gtk is affected. Also, I checked that no other callbacks require a similar change. Looking at the gtk docs the only two event callbacks that need to return true are idle and timeout, and Matplotlib does not use timeout. |
BUG/API : made idle_event() in backend_bases.py return True
|
Great. Thanks for the fix. Although this is technically an API change, I can't think of anything this could break (yes https://xkcd.com/1172/), so I am not going to worry about an api_changes entry for this. I can't think of anyway to test this either. |
|
A little follow-up: I noticed this solves issue 959 |
When using the GtkAgg backend I get the following message every time I close a figure in interactive mode:
This is because, as documented here, the idle event will be removed if the idle event callback returns false. In this case, the idle_event function had no return value (None) which was equivalent to false, so it was immediately removed. When the backend then tried to remove the event upon figure destruction there was a problem. Making idle_event return True solves this problem for me.
Note that this means that previously callbacks attached to idle_event would not work, since
self.callbacks.process(s, event)was not being called after the first idle event.I am running gtk 2.24.25 and pyGtk 2.24.0-5.