On 2014-10-10 19:51, cru...@gmail.com wrote:
Hello. I'm trying to make a colour blink when an event occurs.
But the program is displaying only the last colour:
self.bttn.bind('<ButtonRelease-Return>',blink)
def blink(self, event=None):
lbl['background'] = 'red'
sleep(0.5)
lbl.['background'] = 'SystemButtonFace'
Can you help?
You shouldn't use sleep like that because it'll block the event loop.
Instead, you should use a timed callback that will reset the colour
after a certain amount of time has elapsed, something like this
(untested):
def blink(self, event=None):
lbl['background'] = 'red'
# Assuming that 'main_window' is the main window...
main_window.after(500, reset_color) # Time in milliseconds.
def reset_color():
lbl.['background'] = 'SystemButtonFace'
Have a look here:
http://effbot.org/tkinterbook/widget.htm
--
https://mail.python.org/mailman/listinfo/python-list