如何使用 python 在 tkinter 中的图片上制作文本输入小部件?
我正在使用的代码:
from tkinter import *
from PIL import ImageTk, Image
import os
root = Tk()
root.title('Title')
E1 = Entry(root, bd = 5,show='*') # tried this line of code but it didn't worked
img = ImageTk.PhotoImage(Image.open("path/to/image.png"))
panel = Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
c = Button(text=" OK ")
c.place(relx=0.95, rely=0.98, anchor=SE)
root.mainloop()
可以制作按钮(确定),为什么不能制作输入文本小部件?
最佳答案
您忘记打包条目字段,只需尝试以下操作:
E1 = Entry(root, bd = 5,show='*')
E1.pack(side=BOTTOM, fill=BOTH, expand=YES)
并根据您的喜好自定义位置和行为。
关于python - 使用 python 在 tkinter 中的图片上添加文本输入小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45142786/