-1
entry1 = Text(window, font="Times 15", height=3, width=45)
entry1.place(x=20,y=250)

button1=Button(window, text='Submit',width=10,font="Times 15",fg='darkblue',bg='grey',command=enter)
button1.place(x=20,y=330)

button2=Button(window, text='Reset',width=10,font="Times 15",fg='darkblue',bg='grey',command=reset)
button2.place(x=320,y=330)

entry1.bind('<Return>',enter)

what does the bind function do here and what is its purpose? what is an eventloop and what is the difference between eventloop and mainloop?

1 Answers1

1

Anyway binding means, you bind, kind of like, actions to a widget, such that when you click on certain keys or perform certain actions, the function gets triggered. Look at an example:

import tkinter as tk

window = tk.Tk()

def enter(event):
    print('This is a function triggered by binding')

entry1 = tk.Text(window, font="Times 15", height=3, width=45)
entry1.pack()

entry1.bind('<Return>', enter)

window.mainloop()

Here you are applying bind to the Entry widget. '' means, when you press the enter key it will trigger the function enter(). Note that this enter() requires a parameter event while defining it, for the binding to work. And binding works only when the widget has focus.

You have more than one Q asked in your post and hence it was closed, anyway ive answered one of those, you can make another post if you still want to ask the remaining topics or google it too.

Take a look here for more information on binding.

Also take a look at this Q too

Dharman
  • 30,962
  • 25
  • 85
  • 135
Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46