如何将标签放在左上角?
from tkinter import *
root = Tk()
root.title('title')
root.resizable(width=False, height=False)
root.geometry('800x500+200+100')
root.configure(background='black')
photo = PhotoImage(file='image.png')
label = Label(root, image=photo)
label.pack()
root.mainloop()
如果你只有一个小部件,你可以使用带有参数的包或网格:
label.pack(anchor='nw')
或
label.grid(sticky='nw')
如果你想了解如何构建 GUI,我从 Thinking in Tkinter 中得到了很多
东西然后,您将始终拥有有用的effbot页面:Tkinter Pack Geometry Manager和Tkinter Grid Geometry Manager。