Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- class getTextWindow():
- def __init__(self,prompt,btnText):
- self.theText = None
- self.root = tk.Tk()
- promptElement = tk.Label(self.root, text=prompt)
- promptElement.pack()
- self.entryBox = tk.Entry(self.root, width=50)
- self.entryBox.pack()
- button = tk.Button(self.root, text = btnText,command=self.storeText)
- button.pack()
- self.root.mainloop()
- def storeText(self):
- self.theText = self.entryBox.get()
- self.root.destroy()
- def getText(self):
- return self.theText
- getName = getTextWindow('Enter your name:','Confirm')
- playerName = getName.getText()
- print(playerName)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement