1

I have a problem where to callbacks adding text to Entry without cleaning it and without overwriting: This two fuction is callback in button in tkinter, and when you using it - if adding on front. IDK why All code here: https://pastebin.com/88E9EU57

    def encryptString(text,key,num):
    text = normalizeText(text)
    text = caesarify(text,key)
    text = groupify(text, num)
    data = str(text)
    
    resultFrame1 = tkinter.Frame(master=root, relief="flat", padx=3, pady=3, width=100, bg="LightSteelBlue4")
    title1 =tkinter.Label(master=resultFrame1,text="Your encrypted text:",
                         fg="gray5", font=("Helvetica ", 25), height=1, bg="LightSteelBlue4")
    title1.pack()
    resultOutput1 = tkinter.Entry(master=resultFrame1, text="encrypted text here:", fg="gray13",
                                  width=100, font=("Helvetica", 12), relief="flat", bd=2, bg="LightSteelBlue1")
    resultOutput1.insert(0, data)
    resultOutput1.pack(padx = 5, pady = 5)
    resultFrame1.pack()
    def decryptString(text,key):
    text = ungroupify(text)
    text = caesarify(text,key)
    data2 = str(text)
    
    resultFrame2 = tkinter.Frame(master=root, relief="flat", padx=3, pady=3, width=100, bg="LightSteelBlue4")
    title2 =tkinter.Label(master=resultFrame2,text="Your decrypted text:",
                         fg="gray5", font=("Helvetica ", 25), height=1, bg="LightSteelBlue4")
    title2.pack()
    resultOutput2 = tkinter.Entry(master=resultFrame2, text="encrypted text here:", fg="gray13",
                                  width=100, font=("Helvetica", 12), relief="flat", bd=2, bg="LightSteelBlue1")
    resultOutput2.insert(0, data2)
    resultOutput2.pack(padx = 5, pady = 5)
    resultFrame2.pack()
plaksy
  • 11
  • 2
  • 1
    It is because you used same `text="encrypted text here:"` in `tkinter.Entry(...)` inside the two functions. `text=...` is the same as `textvariable=...`, so you used same string for the `textvariable` option which `tkinter` will create an internal `tkinter` `Variable` implicitly. That means both the `Entry` widgets are referring same `tkinter` `Variable`, so update one `Entry` will also update the other one. Remove `text=...` from those `Entry(...)`. – acw1668 Apr 30 '21 at 02:01

0 Answers0