python - Undo feature in tkinter text widget -


i trying use undo function on text widget in tkinter without luck. tried way:

from tkinter import * ttk import notebook  def onvsb(*args):     text.yview(*args)     numbers.yview(*args)  def onmousewheel(event):     text.yview("scroll", event.delta,"units")     numbers.yview("scroll",event.delta,"units")     return "break"  def undo(*argv):     text.edit_undo()  root = tk() defaultbg = root.cget('bg') root.bind('<control-z>', undo) note = notebook(root) frame = frame(note, bd=5, relief=groove, padx=5, pady=5) frame.pack() bar = scrollbar(frame, command=onvsb) bar.pack(side=right, fill=y) numbers = listbox(frame, width=5, height=30,bg=defaultbg,relief=flat,   yscrollcommand=bar.set) numbers.pack(side=left, fill=y) text = text(frame,bd=3, width=145, height=30, yscrollcommand=bar.set) text.pack(side=left, fill=y)  text.bind("<mousewheel>", onmousewheel) text.tag_config("attr", foreground="tomato") text.tag_config("value", foreground="dark violet") text.tag_config("tags", foreground="dodger blue") text.tag_config("text", font=("georgia", "9", "bold")) text.focus_set() root.lift() root.call('wm', 'attributes', '.', '-topmost', '1') root.after_idle(root.call, 'wm', 'attributes', '.', '-topmost', false) root.mainloop() 

but reason nothing. thought implemented default in text widget, didn't work out. suggestions on how use feature on text widget? example appreciated.

ok, found information finally.

all needed set undo true when initialized text widget, this:

text = text(frame,bd=3, width=145, height=30, yscrollcommand=bar.set, undo=true) 

there no need undo function , text.bind. works automatically when undo true.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -