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

Skip to content

Commit 56504fa

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 100c7cf commit 56504fa

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
@@ -620,6 +620,16 @@ def save_figure(self, *args):
620620
except Exception as e:
621621
tkinter.messagebox.showerror("Error saving file", str(e))
622622

623+
def set_history_buttons(self):
624+
if self._nav_stack._pos > 0:
625+
self._buttons['Back']['state'] = tk.NORMAL
626+
else:
627+
self._buttons['Back']['state'] = tk.DISABLED
628+
if self._nav_stack._pos < len(self._nav_stack._elements) - 1:
629+
self._buttons['Forward']['state'] = tk.NORMAL
630+
else:
631+
self._buttons['Forward']['state'] = tk.DISABLED
632+
623633

624634
class ToolTip:
625635
"""

0 commit comments

Comments
 (0)
0