8000 Implement set_history_buttons for Tk toolbar. · matplotlib/matplotlib@edbca79 · GitHub
[go: up one dir, main page]

Skip to content

Commit edbca79

Browse files
committed
Implement set_history_buttons for Tk toolbar.
This makes the backward/forward buttons change enabled state based on whether there are actually old/new views available.
1 parent 3232f58 commit edbca79

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,16 @@ def save_figure(self, *args):
643643
except Exception as e:
644644
tkinter.messagebox.showerror("Error saving file", str(e))
645645

646+
def set_history_buttons(self):
647+
if self._nav_stack._pos > 0:
648+
self._buttons['Back']['state'] = 'normal'
649+
else:
650+
self._buttons['Back']['state'] = 'disabled'
651+
if self._nav_stack._pos < len(self._nav_stack._elements) - 1:
652+
self._buttons['Forward']['state'] = 'normal'
653+
else:
654+
self._buttons['Forward']['state'] = 'disabled'
655+
646656

647657
class ToolTip:
648658
"""

0 commit comments

Comments
 (0)
0