Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sliders unresponsive when created inside a function #3105

Closed
Milestone
@lebigot

Description

@lebigot

When a Slider is created inside a function, it is typically non-responsive (does not react to the mouse):

from matplotlib import pyplotfrom matplotlib.widgets import Slidersliders = []def open_fig_with_slider():    pyplot.figure()    slider = Slider(pyplot.axes([0.25, 0.1, 0.65, 0.03]),                    'Slider', 0, 1, valinit=0.5)    # sliders.append(slider)open_fig_with_slider()pyplot.show()    # The slider is unresponsive unless append above is un-commented

The problem appears to be fixed by keeping a reference to the slider. The closest thing I've found in the documentation is that a canvas only keeps weak references to itscallbacks (http://matplotlib.org/users/event_handling.html). However, the connection with sliders is not so obvious—if there is any.

If I'm not mistaken, this behavior is not documented, so it would be nice to add it to the documentation, if it is normal.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp