I have a program made in tkinter, where when I start I have a window with 2 buttons, each button calls me a class that said class has several widgets, one of those widgets is an entry. And I want that when I hit ENTER in the entry, I execute a function. I print this
KeyPress event state = Mod2 keysym = Return keycode = 36 char = '\ r' x = 127 y = 21>
The function called is:
def search_Modules (self, txt_Search = None):
try:
search_value = txt_Search
print (search_value)
except:
mb.showerror ("ERROR", "The module is empty or does not exist. \ NTest to search by KEY or the complete MODULE")
The call to that This function was done like this:
self.DESVfr1_entModulo.bind (" Return> ", self.buscar_Modulos)
But it doesn't work. However, if I do it from a button, if it works:
self.DESVfr1_btnBuscar = ttk.Button (self.DESV_frame1,
text = 'Search',
image = self.SearchModulo_icon,
state = 'disabled',
command = lambda: self .buscar_Modulos (self.DESVfr1_entModulo.get ()),
style = 'DESV.TButton')
And it prints the text that I enter in the entry, and I can already work with that text, but I don't know why when I hit ENTER it doesn't work for me. And if in the Return> event, I put the same code as the button, I mean this:
lambda: self.buscar_Modulos (self.DESVfr1_entModulo.get ())
I get this error:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib64/python3.6/tkinter/_init_.py", line 1705, in _call_
return self.func (args)
TypeError: lambda> () takes 0 positional arguments but 1 was given