Python – Using a binder key to move the entry cursor in tinter

So I asked a question earlier in which @TigerhawkT3 assisted me, however now that I am implementing what what suggested over a program involving 2 classes I am running into an error. The code I am working with is as follows:

from tkinter import *

class Calc:
    def __init__(self,parent):
        self.displayentry = StringVar()
        self.display=Entry(parent, textvariable=self.displayentry)
        self.display.pack()
        parent.bind('<Return>', CalculatorLogic.equal_input)

class CalculatorLogic:
    def equal_input(self, event):
        self.display.icursor(END)


root = Tk()
RunGUI=Calc(root)
root.mainloop()

The error I am having with the above code tells me, “TypeError: equal_input() takes exactly 2 arguments (1 given)” when I press the enter key.

Thank you so much for your time and assistance.


Source: python

Leave a Reply