Canvas mặc định load ảnh theo width/height. Điều khiển vị trí ảnh bằng tham số anchor trong Label/Image: N,S,E,W,NS,EW,CENTER...
Để căn giữa: set anchor=CENTER cho Label chứa ảnh.
Ví dụ
# Import tkinter
from tkinter import *
win = Tk()
win.geometry("700x150")
# Label với anchor=CENTER
label_img = Label(win, text="Hello World", font="sans-serif", relief="solid", width=20, height=8, anchor=CENTER)
label_img.pack()
win.mainloop()Kết quả
Chạy code đặt text/hình ở giữa canvas.
