Skip to content

Commit 81ad185

Browse files
committed
Respect position argument in Tk toolmanager
1 parent 695bc25 commit 81ad185

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/matplotlib/backends/_backend_tk.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,14 @@ def _rescale(self):
840840
def add_toolitem(
841841
self, name, group, position, image_file, description, toggle):
842842
frame = self._get_groupframe(group)
843-
button = NavigationToolbar2Tk._Button(self, name, image_file, toggle,
843+
buttons = frame.pack_slaves()
844+
if position >= len(buttons) or position < 0:
845+
before = None
846+
else:
847+
before = buttons[position]
848+
button = NavigationToolbar2Tk._Button(frame, name, image_file, toggle,
844849
lambda: self._button_click(name))
850+
button.pack_configure(before=before)
845851
if description is not None:
846852
ToolTip.createToolTip(button, description)
847853
self._toolitems.setdefault(name, [])
@@ -853,6 +859,7 @@ def _get_groupframe(self, group):
853859
self._add_separator()
854860
frame = tk.Frame(master=self, borderwidth=0)
855861
frame.pack(side=tk.LEFT, fill=tk.Y)
862+
frame._label_font = self._label_font
856863
self._groups[group] = frame
857864
return self._groups[group]
858865

0 commit comments

Comments
 (0)