Advertisement
yoshi_squashy

Proof of concept - multiple line text input with tkinter

May 18th, 2020
1,840
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. import tkinter as tk
  2.  
  3. class getTextWindow():
  4.     def __init__(self,prompt,btnText):
  5.         self.theText = None
  6.        
  7.         self.display = tk.Tk()
  8.        
  9.         promptElement = tk.Label(self.display, text=prompt)
  10.         promptElement.pack()
  11.        
  12.         self.entryBox = tk.Text(self.display)
  13.         self.entryBox.pack()
  14.        
  15.         button = tk.Button(self.display, text = btnText,command=self.storeText)
  16.         button.pack()
  17.        
  18.         self.display.mainloop()
  19.  
  20.     def storeText(self):
  21.         self.theText = self.entryBox.get("1.0", tk.END)
  22.         self.theText = self.theText[:len(self.theText)-1]
  23.         self.display.destroy()
  24.  
  25.     def getText(self):
  26.         return self.theText
  27.  
  28.  
  29. getCode = getTextWindow('Enter the code:','Confirm')
  30.  
  31. playerCode = getCode.getText()
  32.  
  33. print(playerCode)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement