Das sind Hausaufgaben: Versuchen, einen Stroop-Test in Python zu erstellen. Ich habe den größten Teil des Codes bereits geschrieben, aber ich habe Probleme, die passenden Reize nach dem Zufallsprinzip zwischen verschiedenen und gleichen Reizen zu wechseln, wenn ich den "nächsten" Knopf drücke.Stroop-Test in Python funktioniert nicht richtig.
Hier ist mein Code so weit:
# Button, Label, Frame
from Tkinter import *
import random
def stimulus(same):
colors = ['red', 'blue', 'green', 'yellow', 'orange', 'purple']
word = random.choice(colors)
if same == True:
return (word, word)
else:
colors.remove(word)
color = random.choice(colors)
return (word, color)
# create label using stimulus
s = stimulus(same=True)
word, color = stimulus(True)
root = Tk()
label = Label(root, text=word, fg=color)
label.pack()
#create the window
def quit():
root.destroy()
closebutton = Button(root, text = 'close', command=quit)
closebutton.pack(padx=50, pady=50)
def next():
word, color = stimulus(True)
label.congig(text=word, fg=color)
label.update()
nextbutton = Button(root, text='next', comand=next)
nextbutton.pack()
root.mainloop()
Vielen Dank für irgendwelche und alle Hilfe, cdlane! – Mardux