1

How can I make a text entry widget over picture in tkinter using python?
The code I am using:

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

It can make a button (OK) , why it can't make entry text widget?

1 Answers1

3

You forgot to pack the Entry field, just try something like:

E1 = Entry(root, bd = 5,show='*') 
E1.pack(side=BOTTOM, fill=BOTH, expand=YES)

And customize the position and behaviour as you prefer.

Martin Alonso
  • 726
  • 2
  • 9
  • 16
  • How can I change position of it? –  Jul 17 '17 at 11:26
  • If you finally use `pack` as a geometry manager (using only one as @lafexlos suggested) then you can customize position, size, etc. of it by changing its configuration parameters. You will find more of this [here](http://effbot.org/tkinterbook/pack.htm) – Martin Alonso Jul 17 '17 at 11:31
  • I still didn't get how to change position of it. –  Jul 17 '17 at 12:57
  • [Here](http://www.java2s.com/Code/Python/GUI-Tk/LayoutsideTOPLEFT.htm) you will find some layout examples of the `pack`geometry manager, otherwise if you prefer to use another one, this [answer](https://stackoverflow.com/a/10937799) can help you to understand their differences. – Martin Alonso Jul 17 '17 at 13:08
  • 1
    I got it myself. –  Jul 17 '17 at 13:19