我用 tkinter 做了一个简单的猜数游戏,但它不起作用

时间:2021-07-08 03:45:06

标签: python tkinter

我的 tkinter 代码不断出现错误,我在执行 .get() 时遇到问题,我该如何解决?

    from tkinter import *
    root = Tk()
    filler = Label(root, text="").pack()
    from random import randrange as num
    a = num(10)
    enterr = Entry(root).pack()
    def Send():
      if enterr.get() > a:
        lab = Label(root, text="your guess is too big try again").pack()
      elif enterr.get() < a:
        lab = label(root, text="your guess is too small try again").pack()
      else:
        lab = Label(root, text="You got it!")
    filler2 = Label(root, text="").pack()
    button = Button(root, text="Guess a number from 0 - 10", command=Send).pack()
    root.mainloop()

0 个答案:

没有答案