目前,当我写一个标签时,它只会写一行,这有时会从标签的边缘消失,如下所示:
这是我用来写入标签的代码示例:
def updateLabel(self, event):
global string
global labelContents
global windowCommand
global currentEnvironment
if event != "no input":
windowCommand = self.getEntry(event)
labelDisplay = "> " + windowCommand
labelContents += labelDisplay
labelContents += "\n"
self.checkLabel()
string.set(labelContents)
self.textEntry.delete(0, END)
self.master.after(0, play)
else:
self.checkLabel()
string.set(labelContents)
labelContents += "You have died. Game over." + "\n"
labelContents += "You scored {0}.".format(score) + "\n"
app.updateLabel("no input")
我想知道是否有任何方法可以在一定数量的像素(标签宽度)之后强制它换行,而不必经过并在任何地方添加“\ n”(因为最后一行是~150中的1可能性)。