Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78966

Re: Make a colour blink

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'assuming': 0.09; 'callback': 0.09; 'def': 0.12; 'displaying': 0.16; 'event=none):': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'help?': 0.16; 'loop.': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'occurs.': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'reset': 0.22; 'header:User-Agent:1': 0.23; "shouldn't": 0.24; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; "skip:' 10": 0.31; 'something': 0.35; 'received:84': 0.35; 'but': 0.35; 'url:org': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'here:': 0.62; 'email addr:gmail.com': 0.63; 'url:htm': 0.73; 'colour': 0.84; 'subject:Make': 0.91
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=QorQ3DCd c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=m9fHe4oz-9sA:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=pGLkceISAAAA:8 a=g5d77ctgAAAA:8 a=euFRwv6IQ9RsXv1JUZQA:9 a=QEXdDO2ut3YA:10 a=-NDJFg92uDUA:10 a=MSl-tDqOz04A:10
X-AUTH mrabarnett:2500
Date Fri, 10 Oct 2014 20:24:01 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2
MIME-Version 1.0
To python-list@python.org
Subject Re: Make a colour blink
References <4b06699a-8852-4389-8a46-f0d2659322e1@googlegroups.com>
In-Reply-To <4b06699a-8852-4389-8a46-f0d2659322e1@googlegroups.com>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14763.1412969051.18130.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1412969051 news.xs4all.nl 2945 [2001:888:2000:d::a6]:59919
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78966

Show key headers only | View raw


On 2014-10-10 19:51, cruzud@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

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Make a colour blink cruzud@gmail.com - 2014-10-10 11:51 -0700
  Re: Make a colour blink MRAB <python@mrabarnett.plus.com> - 2014-10-10 20:24 +0100
  Re: Make a colour blink Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-10 20:25 +0100
    Re: Make a colour blink Ulisses <cruzud@gmail.com> - 2014-10-10 12:45 -0700

csiph-web