从列表中随机选择单词无法正常工作(Python / Tkinter)

Cid

您好,我正在使用彩色Stroop,我可以使用代码更改单词和单词的颜色,但是当调用函数“ next_selected”时,我不能仅更改单词,有人可以帮我吗请 ?

def tick():
    global doTick
    global sec
    if not doTick:
        return
    sec += 0.1
    sec = round(sec, 1)
    ftest1.after(100, tick)
    time2Label.configure(text=sec)
    if sec == 60.0:
        doTick = False
        time2Label.config(text=sec)
        label1.config(text=score, fg='black')

def start():
    global doTick
    doTick = True
    label1.pack()
    tick()
    startbutton1.destroy()

COLORS = ['blue','green','yellow','red']

def stimulus(same):

    global word
    colors = list(COLORS)

    if same:
        return (word)

    colors.remove(word)

    return (word)

def next_selected():
    global word
    word = stimulus(choice((True,False)))

    label1.config(text=word)
    label1.update()
克兰

stimulus()当我们无法选择一种新的颜色时same=False,也无法在全球范围内保存新的选择word试试看:

COLORS = ['blue', 'green', 'yellow', 'red']

word = COLORS[0]

def stimulus(same):

    global word

    if same:  # return the previous color
        return (word)

    colors = list(COLORS)

    colors.remove(word)

    word = choice(colors)  # chose a different color & remember it

    return word

def next_selected():
    global word
    word = stimulus(choice((True, False)))

    label1.config(text=word)
    label1.update()

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

网格无法正常工作python Tkinter

来自分类Dev

思考Python-无法使Tkinter正常工作

来自分类Dev

在Tkinter中无法使按钮正常工作

来自分类Dev

Tkinter列表框<< ListBoxSelect >>无法正常工作

来自分类Dev

Python Tkinter无法在.py文件中工作

来自分类Dev

Python Tkinter无法在.py文件中工作

来自分类Dev

Tkinter Python gui登录无法正常工作,如何解决?

来自分类Dev

悬停在 Tkinter 中的动态按钮上无法正常工作

来自分类Dev

Tkinter-StringVar()无法正常工作

来自分类Dev

Tkinter的数学IntVar()无法正常工作吗?

来自分类Dev

键盘绑定事件Tkinter无法正常工作

来自分类Dev

Tkinter - 键绑定无法正常工作

来自分类Dev

TkInter - 无法让帧正常工作并调整大小

来自分类Dev

在Python 2.7中的Tkinter文本widgit中搜索单词列表

来自分类Dev

Python and Tkinter

来自分类Dev

Tkinter列表中的Python菜单

来自分类Dev

Tkinter和Python列表

来自分类Dev

在Tkinter中拖放列表

来自分类Dev

Tkinter无法在Python 3中按预期工作

来自分类Dev

Tkinter TkinterHtml无法正常运行

来自分类Dev

列表框无法在Tkinter中自动调整大小(python)

来自分类Dev

brew install python / matplotlib无法正常工作:没有名为_tkinter的模块

来自分类Dev

在Mac中使用终端运行文件时,为什么Tkinter无法在python上正常工作

来自分类Dev

python Tkinter focus_set() 在捕获按键事件时无法正常工作

来自分类Dev

Python中的Tkinter枚举

来自分类Dev

Python,Tkinter中的Getters

来自分类Dev

在Tkinter Python中删除

来自分类Dev

Tkinter几何恢复正常

来自分类Dev

Tkinter几何恢复正常