Search
 
SCRIPT & CODE EXAMPLE
 

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()
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib remove duplicate legend entries from plotting loop 
Python :: tf.reduce_sum() 
Python :: ConfusionMatrixDisplay size 
Python :: windows 10 python path 
Python :: read pickle file 
Python :: python print date, time and timezone 
Python :: python input character limit 
Python :: ubuntu 20.10 python 3.8 
Python :: lemmatization 
Python :: list all files in folder python 
Python :: how to install os module in python 
Python :: python .format 
Python :: clear list 
Python :: pandas df to list of dictionaries 
Python :: root value of a column pandas 
Python :: write image out opencv 
Python :: DJANGO rest framework GET POST 
Python :: python assert is datetime 
Python :: how to specify variable type in python 
Python :: python map() 
Python :: how to go to previous directory in os python 
Python :: empty list in python 
Python :: length of a string python 
Python :: how to use modulo in python 
Python :: switch between frames in tkinter 
Python :: cv2 cuda support print 
Python :: slicing tuples 
Python :: pandas drop duplicates but keep most recent date 
Python :: sympy 
Python :: how to print out even index in python 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =