我需要在 tkinter 中创建一个存储表情符号的字段,但是当有人按下按钮时,该表情符号会被覆盖。我无法在 tkinter 中使用表情符号,我不知道如何覆盖它。
import tkinter as tk
self.option4 = tk.Button(self, width=10)
self.option4["text"] = "no"
self.option4["command"] = self.wrong
self.option4.pack(side="top")
corecalc = ""
self.answercheck = tk.Text(self, height=1, width=5)
self.answercheck.pack()
self.answercheck.insert(tk.END, corecalc)
self.QUIT = tk.Button(self, text="Quit", fg="red", command=root.destroy)
self.QUIT.pack(side="bottom")
def correct(self):
corecalc = "✅"
def wrong(self):
corecalc = "❌"
字段中的预期输出并在按下按钮时变为❌。还有比文本框更好的方法可以使字段固定而不是最终用户可编辑。
错误:_tkinter.TclError: character U+1f532 is above the range (U+0000-U+FFFF) allowed by Tcl