I am trying to make a program that generates a random character design for me to draw using python, but I am trying to make it give me a snippet of the design every two minutes. When I use time.sleep(120), it freezes up and waits until all the answers are generated before it puts them into the list box. Is there anything I can do differently?
def GenerateCharTimed():
import time
listbox.delete(0, END)
listbox.delete(1, END)
listbox.delete(2, END)
listbox.delete(3, END)
listbox.delete(4, END)
listbox.delete(5, END)
characterDrawn = random.choice(beings)
haircolor = random.choice(colors)
charhairstyle = random.choice(hairstyle)
features = random.choice(faceFeatures)
notperson = True
while notperson == True:
characterDrawn = random.choice(beings)
if characterDrawn == "man" or characterDrawn == "boy" or characterDrawn == "girl" or characterDrawn == "woman" or characterDrawn == "ghost" or characterDrawn == "vampire" or characterDrawn == "gnome" or characterDrawn == "skeleton" or characterDrawn == "gnome" or characterDrawn == "zombie" or characterDrawn == "plant monster" or characterDrawn == "humanoid" or characterDrawn == "monster":
notperson = False
if charhairstyle == "no hair":
character = "Your character is a " + characterDrawn + " with a " + features + " face, and with" + " " + charhairstyle + "."
character = str(character)
listbox.insert(END, character)
else:
character = "Your character is a " + characterDrawn + " with a " + features + " face, and with a " + haircolor + " " + charhairstyle
character = str(character)
listbox.insert(END, character)
time.sleep(120)
character = "Your character is wearing " + random.choice(clothing) + "."
character = str(character)
listbox.insert(END, character)
time.sleep(120)
adjLook1 = random.choice(adjectiveLook)
adjLook2 = random.choice(adjectiveLook)
adjLook3 = random.choice(adjectiveLook)
limb1 = random.choice(limbs)
limb2 = random.choice(limbs)
adjLookSimilar = False
if adjLook1 == adjLook2 or adjLook2 == adjLook3 or adjLook3 == adjLook1 or limb1 == limb2:
adjLookSimilar = True
while adjLookSimilar == True:
adjLook1 = random.choice(adjectiveLook)
adjLook2 = random.choice(adjectiveLook)
adjLook3 = random.choice(adjectiveLook)
limb1 = random.choice(limbs)
limb2 = random.choice(limbs)
if adjLook1 != adjLook2 and adjLook2 != adjLook3 and adjLook3 != adjLook1:
adjLookSimilar = False
character = "Your character has " + adjLook1 + " " + limb1 + "."
character = str(character)
listbox.insert(END, character)
time.sleep(120)
character = "Your character has " + adjLook2 + " " + limb2 + "."
character = str(character)
listbox.insert(END, character)