Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. from Tkinter import *
  2.  
  3. root = Tk()
  4.  
  5. class MyOwnEntry:
  6.  
  7. def __init__(self):
  8. self.variable = StringVar()
  9. self.variable.trace("w", self.Validation)
  10. self.MyOwnEntry = Entry(root, textvariable = self.variable)
  11. self.MyOwnEntry.pack()
  12.  
  13. def Validation(self,*args):
  14. self.newvar = self.variable.get()
  15. try:
  16. if isinstance(float(self.newvar),float):
  17. return self.newvar
  18. elif float(self.newvar)<1000:
  19. self.newvar = self.newvar[:-1]
  20. self.variable.set(self.newvar)
  21. else:
  22. self.newvar = self.newvar[:-1]
  23. self.variable.set(self.newvar)
  24. except ValueError:
  25. self.newvar = self.newvar[:-1]
  26. self.variable.set(self.newvar)
  27.  
  28.  
  29.  
  30.  
  31. Input1 = MyOwnEntry()
  32.  
  33.  
  34. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement