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()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构