简体   繁体   中英

How do you change a labels location in tkinter?

How to you put the label in the upper left corner?

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()

If you just have the one widget you can use pack or grid with arguments:

label.pack(anchor='nw')

or

label.grid(sticky='nw')

If you want to understand how you can build a GUI, I've got a lot out of Thinking in Tkinter

Then you will always have the helpful effbot pages: The Tkinter Pack Geometry Manager and The Tkinter Grid Geometry Manager .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM