Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How can write event for textbox in tkinter

from tkinter import *
from tkinter import messagebox

root=Tk()

def alertme(*args):
    messagebox.showinfo("Message", "you press Enter in textbox")

def retrieve_input():
    inputValue=textBox.get("1.0","end-1c")
    print(inputValue)

textBox=Text(root, height=2, width=10)
textBox.pack()

textBox.bind("<Return>", alertme) #this line calls alertme function whenever you press Enter key

buttonCommit=Button(root, height=1, width=10, text="Commit", 
                    command=lambda: retrieve_input())
buttonCommit.pack()
mainloop()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #write #event #textbox #tkinter
ADD COMMENT
Topic
Name
6+7 =