input - Closing a Tkinter Entry Box in Python -


I am trying to create a simple popup text entry for the user in which a user enters a text and submits Does (one button) When I click on submit, I want to close the popup entry box and continue with the rest of the code. The sample code to display below is what I've taken: Tycooner import from * root = Tk () nameLabel = Label (root, text = "name") ent = Entry (root, Bd = 5) def getName (): print ent.get () = submit button (root, text = "submit", command = found), nameLabel.pack () ent.pack () submit.pack (side = Bottom) Route. Mainloop () Print "The rest of the code goes here"

I do not have much experience with the tanker, so I'm not sure where and how to do the proper function to close the entry. The user then hits 'Submit', my guess is that it should be inside the getName () function?

If I understand you correctly, you just need to call the root window method at the end getName function:

  def getName (): print ent.get () root.destroy ()   

Therefore, it is equivalent to manually clicking the X button in the corner of the window.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -