Adding a background image in python

后端 未结 3 1130
猫巷女王i
猫巷女王i 2021-01-05 15:15

I\'m trying to add a background image to a canvas in Python. So far the code looks like this:

from Tkinter import *
from PIL import ImageTk,Image

... other          


        
3条回答
  •  一整个雨季
    2021-01-05 16:06

    from Tkinter import *
    from PIL import ImageTk
    
    canvas = Canvas(width = 200, height = 200, bg = 'blue')
    canvas.pack(expand = YES, fill = BOTH)
    
    image = ImageTk.PhotoImage(file = "C:/Python27/programas/zimages/gato.png")
    canvas.create_image(10, 10, image = image, anchor = NW)
    
    mainloop()
    

提交回复
热议问题