0
How will set image as a background in tkinter (GUI) application ?
import tkinter * w=Tk() w.geometry('500x400') w.config(bg='blue') w.mainloop() above code shows background color is blue. i want to put my image like .jpg .gif .png files as a background. If anyone know means comment below. one constraints is after addition of all my widgets ,there is no changes occurs and all the widget are view on top of the background image only..! Anyone.....???
3 Respostas
+ 2
you can use this
w=Tk()
w.geometry('500x400')
image1= tk.PhotoImage(file"{put in the path of the image here**}")
label_for_image= Label(w, image=image1)
label_for_image.pack()
w.mainloop()
**you don't need to specify the path if the image is in the same directory. In this case, just put in the name of the image within quotes. If not put in the path of the image in double quotes and note that the path will have only '\' and you have to replace them with '\\'
hope this helps you
- 2
but I want exact code! any only help me!!