[Tkinter-discuss] Stopping a for loop with a sleep() funciton in it
ggpolo at gmail.com
Fri Jul 11 00:52:50 CEST 2008
On Thu, Jul 10, 2008 at 7:31 PM, Alexnb <alexnbryan at gmail.com> wrote:
> Guilherme Polo wrote:
>> On Thu, Jul 10, 2008 at 5:57 PM, Alexnb <alexnbryan at gmail.com> wrote:
>>> Okay, so I have a for loop with a sleep command. I want the loop to
>>> until it is told to stop. I want to tell it to stop when a list goes from
>>> empty to having something. The problem is that when that loop starts, the
>>> program pretty much stops with it.
>> You need to remove the use of sleep and use "after" instead. You keep
>> scheduling your task till the condition is not met anymore, then you
>> stop scheduling it with "after".
>>> To make things harder, I really want that
>>> to be it's own class, so I have to pass it the list that triggers the
>>> stopping, but I can only pass it the list once. So I don't think it is
>> It is, just pass some other object along which can call the method
>>> But if this made sense to anyone, and you have a suggestion I
>>> would love it. Heres the full code: (but at the bottom, the Open function
>>> really the only thing that matters)
>> If you want help based on code, you have to post a short-enough code
>> that demonstrates the problem.
>>> from Tkinter import *
>>> import time
>>> class BusyBar(Frame):
>> -- Guilherme H. Polo Goncalves
>> Tkinter-discuss mailing list
>> Tkinter-discuss at python.org
> Okay, so I modified the bottom code to this:
> def Open(root):
> bb = BusyBar(root, text='Grabbing Definitions')
> bb.pack(side=LEFT, expand=NO)
> def sleeper():
What if you change this to root.update() ?
> root.after(1, sleeper)
after works with milliseconds, not seconds, be aware.
> #for i in range(0, 100):
> but it doesn't repeat. What am I missing?
-- Guilherme H. Polo Goncalves
More information about the Tkinter-discuss