python canvas.create_text在图像下面显示文本而不是在图像上面

hs1rzwqc  于 2023-01-04  发布在  Python
关注(0)|答案(1)|浏览(267)

这是我的代码-我试图创建_text并将其放置在图像上,但当运行代码时,我只能看到它甚至出现,如果我在位置0,0创建它,位置400,263的其他文本不显示(因为它放置在图像下)

window = Tk()
window.title("Flash Card")
window.config(pady=50, padx=50, background=BACKGROUND_COLOR)

canvas = Canvas(width=800, height=526)
french_background = PhotoImage (file ="images/card_front.png")
canvas.create_image(400, 263, image=french_background)
canvas.create_text(0, 0, text="French", fill= "black" , font=("Ariel", 40, "italic"))
canvas.create_text(400,263, text=random_french, fill="black", font=("Ariel",60,"bold"))
canvas.config(bg=BACKGROUND_COLOR, highlightthickness=0)
canvas.grid(row=0, column=0, columnspan=2)

output of the code on my end

jvlzgdj9

jvlzgdj91#

canvas.grid之后使用canvas.create_text

canvas.grid(row=0, column=0, columnspan=2)

canvas.create_text(0, 0, text="French", fill= "black" , font=("Ariel", 40, "italic"))

canvas.create_text(400,263, text=random_french, fill="black", font=("Ariel",60,"bold"))

相关问题