0
我已经在我的笔记本电脑上用python和tkinter开发了一些应用程序。然后,我被困在某个地方。问题是:如何更改图像上的文字位置。Tkinter:如何更改文本在图像上的位置
import tkinter as tk
from PIL import Image, ImageTk
path_to_pic = "....."
root = tk.Tk()
pic = Image.open(path_to_pic)
tkpic = ImageTk.PhotoImage(pic)
tk.Label(root, image = tkpic, text = ".....", compound = tk.CENTER).pack()
root.mainloop()
这表明我的文字出现在图片上,只在中心。我想一点一点地移动我的文本,找到最佳位置。你知道任何解决方案或类似的方式来实现这一目标吗?
如何填写旧文本空间? – dsgdfg
您可以通过向您希望的任何一侧添加空格来水平移动文本。 –
对于垂直移动,您可以使用'\ n'。 –