现在我正试图通过简单地打印它所持有的值来测试我的条目小部件,但 .get() 似乎不起作用。我在看什么?
from tkinter import *
class Game(Frame):
'Number guessing application'
def __init__(self,parent=None):
'constructor'
Frame.__init__(self, parent)
self.pack()
Game.make_widgets(self)
Game.new_game(self)
self.number = random.randrange(1,100)
self.pack()
def make_widgets(self):
self.entry = Entry(self, width = 25, bg = 'purple',fg= 'green')
self.entry.pack()
self.button = Button(self,text = 'Enter',relief = 'ridge',command = self.reply())
self.button.pack()
def new_game(self):
pass
def reply(self):
print(self.entry.get())
Game().mainloop()