factor = x - here
x0 = y/factor
y0 = z/factor
r0 = r/factor複製代碼
root = Tk() #創建窗口
canvas = Canvas(root,width=win.width,height=win.height) #在窗口上創建畫布
canvas.pack() #擺上畫布
im = Image.open('filename.png') #開啓圖檔
photo = ImageTk.PhotoImage(image=im) #轉成PhotoImage物件
Id = canvas.create_image(x, y, image=photo) #放到畫布(x,y)位置
#Id則做之後面要做任何動做的依據
canvas.coords(Id, x, y) #移動位置複製代碼
canvas.create_oval(x0, y0, x1, y1, fill=color) # 畫(橢)圓在畫布上
canvas.coords(Id, x0, y0, x1, y1) # 更動位置
# 顯示及消失: 基本上以canvas.create_image及canvas.create_oval來顯示,
# 以canvas.delete(Id)來刪除.複製代碼
def function():
pass # do somthing here
root.after(time, function)
root.after(time, function)複製代碼
overlap = canvas.find_overlapping(x0, y0, x1, y1) # 找到對象列表
overlap[index] in canvas.find_withtag(tag) # 確認帶有該標籤tag的對象複製代碼
font = ImageFont.truetype("filename.ttf", font_size) # 創建字型及其大小
im = Image.new('RGBA', (width, height)) # 創建含有alpha層的空圖像
im.putalpha(0) # 設置alpha層的內容都爲0(透明)
draw = ImageDraw.Draw(im) #改成ImageDraw物件
draw.text((x,y), text, fill=color, font=font) # 畫上文字
image = ImageTk.PhotoImage(im) # 轉成PhotoImage物件
Id = canvas.create_image(x, y, image= image) # 放到畫布(x,y)位置複製代碼
交流羣:887934385 須要源代碼請加羣獲取,免費提供python