Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Tkinter import *
- root = Tk()
- class MyOwnEntry:
- def __init__(self):
- self.variable = StringVar()
- self.variable.trace("w", self.Validation)
- self.MyOwnEntry = Entry(root, textvariable = self.variable)
- self.MyOwnEntry.pack()
- def Validation(self,*args):
- self.newvar = self.variable.get()
- try:
- if isinstance(float(self.newvar),float):
- return self.newvar
- elif float(self.newvar)<1000:
- self.newvar = self.newvar[:-1]
- self.variable.set(self.newvar)
- else:
- self.newvar = self.newvar[:-1]
- self.variable.set(self.newvar)
- except ValueError:
- self.newvar = self.newvar[:-1]
- self.variable.set(self.newvar)
- Input1 = MyOwnEntry()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement