Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_entry_instant_relay.py
- import tkinter
- root = tkinter.Tk()
- myvar = tkinter.StringVar()
- myvar.set('')
- mywidget = tkinter.Entry(root,textvariable=myvar,width=10)
- mywidget.pack()
- def instant_relay(*t):
- t = myvar.get()
- color = 'red blue cyan lightgreen yellow'.split()[len(t)%5]
- mywidget.config(bg=color)
- mywidget.update_idletasks()
- myvar.trace('w',instant_relay)
- root.mainloop()
Add Comment
Please, Sign In to add comment