Python错误解释了我的列表

时间:2015-10-04 19:35:56

标签: python tkinter

出于某种原因,Python不断抛出TCL错误,其中显示“未知颜色”。尽管事实上它所采用的字符串与颜色无关。这有什么理由吗?

#Add words to this list to include them in the game
words = ["Games","Development","Keyboard","Speed","Typer","Anything","Aplha","Zealous","Accurate","Basics","Shortcut","Purpose","Window","Counter","Fortress","Modification","Computer","Science","History","Football","Basketball","Solid","Phantom","Battlefield","Avdvanced","Warfare","Download","Upload","Antidisestablishmentarianism","Supercalifragilisticexpialidocious","Discomobobulation","Liberated","Assassin","Brotherhood","Revelation","Unity","Syndicate","Victory"]

def nextWord():
        global score
        entry.focus_set()
        if entry.get().lower() == words[1].lower():
            score += 1

        entry.delete(0, tkinter.END)
        random.shuffle(words)
        label.config(fg=str(words[1]), text=str(words[0]))
        scoreLabel.config(text="Score: " + str(score))

这是新的错误:

ValueError: dictionary update sequence element #0 has length 1; 2 is required

此外,我知道我的一些/大部分代码可能不正确,我想知道如何设置最大次数来随机播放并显示字符串,然后再打印它们通过所有代码前进的时间他们在一个标签。 (次要问题,如果你不想,不要回答) 感谢。

1 个答案:

答案 0 :(得分:1)

你明确告诉tkinter使用这个词作为颜色;这是fglabel.config(fg=str(words[1]),...)行中的作用。

由于它不是一种颜色,你不应该这样做。