你的小工具名是
myScrolledText
,不是
scrolledtext
:(scrolledtext是导入的模块名)
from tkinter import *
from tkinter import scrolledtext
startingWin = Tk()
myEntry = Entry(startingWin, font=("Courier",25, "bold"), width=15)
myScrolledText = scrolledtext.ScrolledText(startingWin, font=("Courier",25, "bold"),width=15, height=3, state='disabled')
def addEntryContentToScrolledText(entry, textwidget):
entryValue = str((entry.get()).strip())
textwidget.configure(state='normal')
if entryValue not in str(textwidget.get('1.0', 'end-1c')) and entryValue != "":
textwidget.insert(INSERT, (entryValue + "\n"))
textwidget.configure(state='disabled')
myAddButton = Button(startingWin, text="Add", command=lambda: addEntryContentToScrolledText(myEntry, myScrolledText))
myScrolledText.grid(row=0, column=1)
myEntry.grid(row=0, column=0)
myAddButton.grid(row=1, column=0)
startingWin.mainloop()