我有一个程序,它接受用户的输入并使用该Population()函数显示输入的多种变体。该store_fit函数将这些不同的变体添加到列表中,然后将它们删除,以便列表一次仅填充一个变体。
我希望能够从列表中获取变体并使用它来更新我的文本。Population但是,我的程序仅在功能完成后才更新文本。我怎样才能运行该Population功能并同时更新我的文本?
代码:
fit = []
...
def store_fit(fittest): # fittest is each variation from Population
clear.fit()
fit.append(fittest)
...
pg.init()
...
done = False
while not done:
...
if event.key == pg.K_RETURN:
print(text)
target = text
Population(1000) #1000 variations
store_fit(value)
# I want this to run at the same time as Population
fittest = fit[0]
...
top_sentence = font.render(("test: " + fittest), 1, pg.Color('lightskyblue3'))
screen.blit(top_sentence, (400, 400))
智慧大石
相关分类