Skip to content

tk toolmanager add_toolitem fails to add tool to group other than the last one #20130

Closed
@anntzer

Description

@anntzer

Bug report

Bug summary

The list of default tools in backend_tools is currently defined as

default_toolbar_tools = [['navigation', ['home', 'back', 'forward']],
                         ['zoompan', ['pan', 'zoom', 'subplots']],
                         ['io', ['save', 'help']]]

Let's just break the "zoompan" group in two:

default_toolbar_tools = [['navigation', ['home', 'back', 'forward']],
                         ['zoompan', ['pan', 'subplots']],
                         ['io', ['save', 'help']],
                         ['zoompan', ['zoom']]]

(a more realistic case would be a third-party tool which wants to insert itself into a preexisting group).
For Qt, GTK3 and wx (open a figure while rcParams["toolbar"] = "toolmanager"), the "zoom" tool ends up in the same group (i.e., next to) "pan" and "subplots" (well, the ordering is slightly messed up, but let's think about that another time). However, for tk, the "zoom" tool ends up by itself after all other tools.

Looking at the implementation of add_toolitem

    def add_toolitem(
            self, name, group, position, image_file, description, toggle):
        frame = self._get_groupframe(group)
        button = NavigationToolbar2Tk._Button(self, name, image_file, toggle,
                                              lambda: self._button_click(name))

it seems likely that we should be doing something with frame...

Code for reproduction
Actual outcome
Expected outcome

discussed above.

Matplotlib version

  • Operating system: linux
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): HEAD/3.4.x
  • Matplotlib backend (print(matplotlib.get_backend())): tkagg
  • Python version: 39

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions