Hello.
How can i set an image as a Tkinter window background? I mean the whole background of the window not a photo area.

You could perhaps create an image in a canvas widget, then draw other widgets above the canvas.

This is an example code:

#!/usr/bin/env python3
# -*-coding: utf8-*-

from Tkinter import *

root = Tk()
photo = PhotoImage(file = "bg.gif")
w = Label(root, image=photo)
w.pack()

ent = Entry(root)
ent.pack()
ent.focus_set() 

root.mainloop()

With the code above; a window appears with an image background; but the entry box will be places out of that background, under the image. But i want the entry box to be places on the middle of the photo area.

We set the window background with this for example:

root.configure(background = 'AntiqueWhite1')

I want to set an image instead of a color.

ent = Entry(w)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.