Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
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 between
enable()
anddisable()
, 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 namedfooEvent()
(mouseMouveEvent()
), rather thando_foo()
. I don't have a
very strong preference between e.g.on_toggle(state: bool)
andtoggle_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.