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

Improve the ToolToggleBase API #18331

Open
@anntzer

Description

@anntzer

Describe the issue

Currently the MEP22 ToolToggleBase API is that toggle-tool implementers should
implement anenable() method and adisable() method, which Matplotlib
arranges to be called when the tool is toggled. I think it would be nicer to
instead have a singleon_toggle(state: bool) method.

  • Having a single method avoids duplicating logic betweenenable() and
    disable(), given that both are often quite similar (seeToolFullScreen,
    AxisScaleBase, orGroupHideTool from thetoolmanager_sgskip example).

  • Using a non-verb method name makes it clearer that this is not something that
    end users cancall themselves and expect to work (indeed it would cause
    problems, given that the widget state wouldn't get updated). Compare e.g.
    with Qt's approach, which is also based on implementing special method names
    in subclasses (yes, Qt also lets you bind arbitrary callables (slots) but
    that's not the MEP22 design): these overridable methods are typically named
    fooEvent() (mouseMouveEvent()), rather thando_foo(). I don't have a
    very strong preference between e.g.on_toggle(state: bool) and
    toggle_event(state: bool), although the latter may be confused with string
    event names?

This can relatively easily be implemented with a transition period using
_deprecate_method_override, I think.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp