打开tkin的文本框小部件

2024-09-30 10:36:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我在tkinter中打开文本框小部件时遇到问题

    self.usrText1 = Text(self.usrDetailsFrame, height=4, width=15)
    self.usrText1.insert(END, "Enter Text")
    self.usrText1.grid(row=8, column=1, sticky=W, padx=3)

现在,当我尝试用一个包含多行的字符串更新文本框时,我得到了一个字符串的包装版本,这会导致"\n".join(self.person.getBooks())中格式非常好的字符串失真

    self.usrText1.delete("1.0",END)
    self.usrText1.insert(END,"\n".join(self.person.getBooks()))

如何打开文本框?或者添加滚动条?请注意,我使用的是Python2.7,谢谢


Tags: 字符串textself部件tkinterwidthendperson

热门问题