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

Commit6515cbc

Browse files
committed
Arbitrary toolbar customization hooks.
MEP22 was intended to provide a way to customize user interactions,in particular with the toolbar via the implementation to "tools". Inpractice, it remains currently difficult to add general customizations;for example, the color-vision deficiency simulator recently proposeddoes not fit in the MEP22 framework. Moreover, there is no way toregister MEP22 tools to be added to all figures.This patch proposes an alternative approach for toolbar customization:it adds a rcParam (`figure.hooks`) which is a list of callables(actually, of "modulename:functioname" strings, so that they canbe specified in the matplotlibrc file) that get called wheneverplt.figure() creates a figure is instantiated; each of the callable getsthe figure as parameter and can modify it as it sees fit (note that itis equivalent to pass the figure or the toolbar as parameter, as onecan reach one from the other; passing the figure was deemed nicer).This makes it easy to distribute such customizations as plain pythonmodules than can be installed from PyPI. Also note that figure hooksare intentionally *not* applied when figures are created without goingthrough `plt.figure` -- when embedding, one can easily explicitly callthe hooks directly on the figure (this is one reason why passing thefigure is nicer than passing the toolbar).As an example, the color-vision deficiency simulator is modified to usethis hook (see docstring of the `user_interfaces/mplcvd.py` example).The advantage of this approach is that arbitrary modifications to thetoolbar become possible (here, adding a menu-in-a-toolbar), but thisnaturally means that each GUI toolkit needs its own code. Likely wewill need to provide "template" implementations that can be copiedby third-parties. (There is also some functionality currently onlyavailable as private API, as mentioned in comments; one such API is`_icon`, which provides theme-dependent icon recolorization. These APIsshould be made public in some form, but that should be doable.)(One should check to what extent this approach is generalizable tothe macos and notebook backends -- customizations to the former couldpossibly be implemented via PyObjC(?), and the latter via js injection?)
1 parentc0c3627 commit6515cbc

File tree

9 files changed

+417
-1
lines changed

9 files changed

+417
-1
lines changed
Lines changed: 70 additions & 0 deletions
Loading
3.44 KB
Binary file not shown.
635 Bytes
Loading
Lines changed: 70 additions & 0 deletions
Loading
1.12 KB
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp