I am creating a code editor and I get a minimap with help of this https://stackoverflow.com/a/71895218/18364950
But I having facing some problem with it that is whenever I attached it with my editor area(Text widget) my undo function is not working actually cursor moves back but the recent work is not removing as all undo function working If you can solve this problem please help me to solve my problem
please help
this is my code
import tkinter as tk
class TextPeer(tk.Text):
"""A peer of an existing text widget"""
count = 0
def __init__(self, master, cnf={}, **kw):
TextPeer.count += 1
parent = master.master
peerName = "peer-{}".format(TextPeer.count)
if str(parent) == ".":
peerPath = ".{}".format(peerName)
else:
peerPath = "{}.{}".format(parent, peerName)
# Create the peer
master.tk.call(master, 'peer', 'create', peerPath, *self._options(cnf, kw))
# Create the tkinter widget based on the peer
# We can't call tk.Text.__init__ because it will try to
# create a new text widget. Instead, we want to use
# the peer widget that has already been created.
tk.BaseWidget._setup(self, parent, {'name': peerName})
root = tk.Tk()
editor = tk.Text(root,font=("JetBrains Mono",15),undo=True)
editor.pack(side=tk.LEFT,expand=True,fill=tk.BOTH)
minimap = TextPeer(editor,font=("JetBrains Mono",4),state="disabled")
minimap.pack(side=tk.RIGHT,fill=tk.Y)
root.mainloop()