Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use lambdas to prevent gc'ing and deduplication of widget callbacks. #18923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions doc/api/next_api_changes/behavior/18226-ES.rst

This file was deleted.

10 changes: 5 additions & 5 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def on_clicked(self, func):

Returns a connection id, which can be used to disconnect the callback.
"""
return self._observers.connect('clicked', func)
return self._observers.connect('clicked', lambda event: func(event))

def disconnect(self, cid):
"""Remove the callback function with connection id *cid*."""
Expand Down Expand Up @@ -483,7 +483,7 @@ def on_changed(self, func):
int
Connection id (which can be used to disconnect *func*)
"""
return self._observers.connect('changed', func)
return self._observers.connect('changed', lambda val: func(val))

def disconnect(self, cid):
"""
Expand Down Expand Up @@ -646,7 +646,7 @@ def on_clicked(self, func):

Returns a connection id, which can be used to disconnect the callback.
"""
return self._observers.connect('clicked', func)
return self._observers.connect('clicked', lambda text: func(text))

def disconnect(self, cid):
"""Remove the observer with connection id *cid*."""
Expand Down Expand Up @@ -897,7 +897,7 @@ def on_text_change(self, func):

A connection id is returned which can be used to disconnect.
"""
return self._observers.connect('change', func)
return self._observers.connect('change', lambda text: func(text))

def on_submit(self, func):
"""
Expand All @@ -906,7 +906,7 @@ def on_submit(self, func):

A connection id is returned which can be used to disconnect.
"""
return self._observers.connect('submit', func)
return self._observers.connect('submit', lambda text: func(text))

def disconnect(self, cid):
"""Remove the observer with connection id *cid*."""
Expand Down