0

I just wondering what I should do to apply an image as background of my tkinter window. I want this window with a gif image in the background and a few buttons on top of it..

the error msg says: "x.image = bg_image.grid(row = 0, column = 0) AttributeError: 'PhotoImage' object has no attribute 'grid'"

do I need to import something else? whats wrong? I dont even know if this PhotoImage code is supported by this version of python (python 3.1.1)...

from tkinter import*

window = Tk()
window.title("ksdasndsnadn")

bg_image = PhotoImage(file ="pic.gif")
x = Label (image = bg_image)
x.image = bg_image.grid(row = 0, column = 0)


window.geometry("600x300")
app = Application(window)
window.mainloop()
user3132508
  • 93
  • 1
  • 3
  • 10

1 Answers1

2

You need to apply the grid method to the label that contains the image, not the image object:

bg_image = PhotoImage(file ="pic.gif")
x = Label (image = bg_image)
x.grid(row = 0, column = 0)

http://effbot.org/tkinterbook/photoimage.htm

atlasologist
  • 3,824
  • 1
  • 21
  • 35
  • Thanks for that... but do you know how to place the button on top of it? my buttons were pushed by the size of the picture... thanks again – user3132508 Apr 09 '14 at 14:21