我正在使用 itertools.combinations 模块来查找大量组合。当我的程序找到它的所有组合(很多)时,它会检查每个组合的总和是否为某个数字,然后程序将该组合存储在列表中。
from itertools import *
from math import *
import Tkinter as tk
import ttk
x = int(raw_input('Enter number of combinations: '))
z = int(raw_input('Enter sum number: '))
def combinator():
comb = combinations(range(100), x)
for i in comb:
yield i
my_combinations = []
combination_s = combinator()
for i in combination_s:
print i
c = list(i)
if fsum(c)==z:
my_combinations.append(c)
print my_combinations
root = tk.Tk()
root.title('ttk.Progressbar')
pbar = ttk.Progressbar(root, length=300, mode='determinate', maximum = 100)
pbar.pack(padx=5, pady=5)
root.mainloop()
我想让 ttk.progressbar 显示每次程序评估组合总和时的进度。我怎样才能做到这一点?