What is the simplest way to run a constant loop in a tkinter frame?
<p>I want to run a method in the background of my tkinter frame that will constantly check if certain files exist in a specific folder. As long as the files dont exist, there will be a red <code>tk.label</code> that says "Incomplete", and as soon as it detects these specific files, the <code>tk.label</code> will turn green and say "Complete".</p>

<p>The problem is that my method only runs when the frame is initialized, which is as soon as the program opens. If these files are added or removed after the program is opened, the method won't realize, and the <code>tk.label</code> wont change.</p>

<p>What is the best way to run a constant checker in the background? Preferably one that only runs when the frame is opened. Is it just a neverending <code>while</code> loop?</p>

<p>Define a function that does whatever you want, and have that function schedule itself to be run again in the future. It will run until the program quits.</p>

<p>This example assumes a global variable named <code>root</code> that refers to the root window, but any widget reference will work.</p>

<pre><code>def do_something():
    &lt;your code here&gt;
    root.after(3000, do_something)
</code></pre>

<p>Call it once to start it, and then it will run forever</p>

<pre><code>do_some_check()
</code></pre>

python python-2.7 tkinter tk