Canvas 画布

复制代码
import tkinter as tk

window = tk.Tk()
window.title("daxiangcai's title")
window.geometry('800x400')

canvas = tk.Canvas(window, bg='green', height=100, width=200)
imagefile = tk.PhotoImage(file='')
image = canvas.create_image(10, 10, anchor='nw', image=imagefile)  # anchor代表放在坐标处的图片上的点,此处为nw(north west)
x0, y0, x1, y1 = 50, 50, 80, 80
line = canvas.create_line(x0, y0, x1, y1)
oval = canvas.create_oval(x0, y0, x1, y1, fill='red')
arc = canvas.create_arc(x0, y0, x1, y1, start=0, extend=180)
rect = canvas.create_rectangle(100, 30, 100+20, 30+20)


def move():
    canvas.move(rect, 0.2)  # 移动长方形
    

canvas.pack()

window.mainloop()
复制代码

 

posted @   树叶本子  阅读(24)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示