1

I'm sorry if this is a stupid question, but I'm not sure what I am doing wrong here. The undo and redo worked perfectly fine on Linux but it will not work on Windows. I tried to create a binding manually (as seen below) but that also didn't solve the problem. I try this exact code below and the redo command does not work. I have researched the problem, but I only find the binding solution, which I have already tried.

import tkinter as tk

class TextThing():
    def __init__(self, master):
        self.text = tk.Text(undo=True, maxundo=-1, autoseparators=True)
        self.bindings()
        self.text.pack()

    def bindings(self):
        self.text.bind('<Control-Shift-z>', self.text.edit_redo)

if __name__ == '__main__':
    master = tk.Tk()
    text_thing = TextThing(master)
    master.mainloop()
  • The default binding for undo is control-y on windows. Does that work? If you're going to bind to `edit_redo` you're going to have to catch the event object since that function doesn't accept an option. – Bryan Oakley Oct 27 '20 at 22:20
  • control-y seems to work, thank you for the information! – Seth Walker Oct 27 '20 at 22:33
  • The information is in the official tcl/tk documentation, but it's a bit hard to spot if you don't know it's there. – Bryan Oakley Oct 27 '20 at 22:49

1 Answers1

0

You need to bind "Control-Shift-Z" (uppercase "Z") because if the shift key is pressed you get an upper case "Z" not a lower case "z".

Conrad
  • 21
  • 2