Ridertvis
Ridertvis

Reputation: 223

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

Upvotes: 0

Views: 234

Answers (1)

figbeam
figbeam

Reputation: 7176

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.

Upvotes: 1

Related Questions