0
これは宿題です:PythonでStroopテストを作成しようとしています。私はすでにコードのほとんどを書いていますが、一致する刺激を作る際に問題があります。 「次の」ボタンを押すと、ランダムに異なる刺激を切り替えます。PythonのStroopテストが正しく機能していません。
はここで、これまでに私のコードです:
# 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()
何かすべてのヘルプのために、cdlane! – Mardux