本文介绍了带有图像的Python Tkinter画布矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我想知道如何用图像而不是颜色填充canvas.rectangle.
Hello I would like to know how can I fill a canvas.rectangle with an image but not a colour.
这是我的代码:
def P1():
def square():
x1,y1,x2,y2=0,675,75,750
for i in range(0,10):
for f in range(0,10):
can1.create_rectangle(x1,y1,x2,y2,fill="blue")
x1=x1+75
x2=x2+75
list.append((x1,x2,y1,y2))
x1,x2=0,75
y1=y1-75
y2=y2-75
can1.create_rectangle(x1,y1,x2,y2,fill="blue")
list.append((x1,x2,y1,y2))
谢谢.
推荐答案
您不能用fillImage之类的内容替换填充,因为它不存在.您应该以此为基础在现有画布中创建一个新画布.
You can't replace the fill with something like fillImage because it doe not exists.you should create a new canvas in you existing one with this.
photo = tkinter.PhotoImage(file = './test.gif')
canvas.create_image(0,0, image=photo)
这篇关于带有图像的Python Tkinter画布矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!