Is it possible to run a function with both a button press and an event? When I try to run this function by pressing the button, it, understandably, gives an error
TypeError: listFiller() missing 1 required positional argument: 'event'.
Couldn't find a similar problem, but maybe that is just my lack of programming knowledge.
Code:
class MyClass:
def __init__(self, master):
self.myButton = tk.Button(master, text='ok', command=self.listFiller)
self.myButton.pack()
self.myEntry = tk.Entry(master)
self.myEntry.bind("<Return>",self.listFiller)
self.myEntry.pack()
def listFiller(self, event):
data = self.myEntry.get()
print(data)