1
from functools import partial
from random import randint
from tkinter import *
def click3(a,b, c):
if int(a) == b:
c.delete(0.0, END)
c.insert(END,"That's correct!")
elif int(a) < b:
c.delete(0.0, END)
c.insert(END,"A bit higher")
elif int(a) > b:
c.delete(0.0, END)
c.insert(END,"A bit lower")
gtnCorrect = randint(1,1000)
gtnWin = Tk()
gtnWin.title("Guess the number")
gtnWin.configure(bg='black')
Label(gtnWin, text = "Guess a number from 1-1000", bg='black',fg='white',font = '10').grid(row=0,column=0,sticky=W)
gtnGuess = Entry(gtnWin, width = 10, bg='white')
gtnGuess.grid(row = 1,column=0,sticky=W)
op = Text(gtnGuess, width = 20, height = 1, wrap=WORD,background='white')
op.grid(row = 2, column = 0,sticky=W)
part2 = partial(click3, gtnGuess.get(),gtnCorrect,op)
Button(gtnWin, text = "Submit", width = 6, command = part2).grid(row = 3,column=0,sticky=W)
我的代碼的這部分工作不正常,我想知道是否有人知道爲什麼。當我運行它時,輸入框不顯示,只有標籤,文本框和提交按鈕。
感謝