My Coding >
Programming language >
Python >
Python graphics >
Matplotlib >
Matplotlib Widgets >
How to pass arguments to function called by on_changed in Matplotlib Widgets
How to pass arguments to function called by on_changed in Matplotlib WidgetsThe main idea of any Matplotlib Widgets, is to call method on_changed, when anything changed in the Widget, for example movement of Slider or switching Radiobuttons, or changing status of CheckButtons. But the format of defining of this function do not give straight forward way to send any parameters except default one. And the question, how to send required parameters. This is a standard way of making this call is:
where val is the parameter by default taken from the Widget status. To submit any parameters, it is necessary to make lambda function of this call.
In this code we call function slider_update with two parameters - new_val with is default parameter, and my_variable - extra variable with we need to pass to this function. In the function these two variables will be val and slider_update, respectively. This method is applicable for any Matplotlib Widgets working on this principle responding vide on_changed method
|
Last 10 artitles
9 popular artitles
|
|
© 2020 MyCoding.uk -My blog about coding and further learning. This blog was writen with pure Perl and front-end output was performed with TemplateToolkit. |