【发布时间】:2022-11-17 15:02:20
【问题描述】:
我的意思是我正在读取一个 txt 文件,对于 txt 文件中的每一行我 想要一个新标签。
root = tk.Tk()
#here it opens the file
with open("/file.txt", "r") as openedFile:
allLines = openedFile.readlines()
for line in allLines:
textInLine = line
testText = Label(root, text=textInLine)
testText.pack()
root.geometry("400x300")
root.mainloop()
在文本文件中,行的长度不一样,所以它把标签文本水平居中,我希望它贴在最左边。
【问题讨论】: