2

So, for the program I have 2 lists, one that starts out with say 100'000 integers and one that starts out empty but will eventually be filled with all the prime numbers from the first list.

What I want is a messagebox that continuously updates with the length of the second list and when the first list is all scanned/empty displays a message that the first list is empty and the scan is done.

I'm assuming update_idletasks would be involved but I'm having trouble finding somekind of tutorial for this.

thanks in advance

4

1 に答える 1

2

python3 の使用:

from tkinter import *
from tkinter.ttk import *

def isPrime(num):
    return all(num % i for i in range(2, num))

def startSearching():
    primes = []
    for i in range(100000):
        if isPrime(i):
            primes.append(i)
            displayedText.set(len(primes))
            label.update_idletasks()
    displayedText.set('Scan is done.')

root = Tk()

displayedText = StringVar()

label = Label(root, textvariable=displayedText)
label.grid()

root.after(0, startSearching)
root.mainloop()
于 2013-06-29T15:50:14.137 に答える