python - Checking if the user presses 'Return' while selected in an Entry box Tkinter -


i'm using tkinter create gui simple geometry calculator i'm creating.

basically, have entry box. want program/gui/system detect when user of program hits 'enter' or 'return' key while in entry box. when detected, want contents of entry box appended list have defined earlier. want simple label created on gui displays contents of list (including appended item(s)). note list begins nothing in it.

here code far:

from tkinter import * #window setup(ignore this) app = tk() app.title('geometry calculator') app.geometry('384x192+491+216') app.iconbitmap('geo.ico') app.minsize(width=256, height=96) app.maxsize(width=384, height=192) app.configure(bg='whitesmoke') #this emtry list... pointlist = [] #here define variable appending list (which              object of entry box below) strpoint = stringvar() def list_add(event): #i don't know how bind-checking works , how implement it; want check if user hits enter while in entry box here     if event.char == '':         pointlist.append(strpoint) e1 = entry(textvariable=strpoint).grid(row=0, column=0) app.bind('<return>', list_add)  mainloop() 

i don't know proper way check 'return' , use in if statement. hope understand i'm trying with, , i've looked around explanation understand no success.

instead of binding app bind entry widget object,i.e,e1

from tkinter import * #window setup(ignore this) app = tk() app.title('geometry calculator') app.geometry('384x192+491+216') app.iconbitmap('geo.ico') app.minsize(width=256, height=96) app.maxsize(width=384, height=192) app.configure(bg='whitesmoke') #this emtry list... pointlist = [] #here define variable appending list (which              object of entry box below) strpoint = stringvar() def list_add(event):     print ("hello") #i don't know how bind-checking works , how implement it; want check if user hits enter while in entry box here     if event.char == '':         pointlist.append(strpoint) e1 = entry(textvariable=strpoint) e1.grid(row=0, column=0)#use grid in next line,else return none e1.bind('<return>', list_add)# bind entry  mainloop() 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -