首页 > 解决方案 > 如何使用 Tkinter-canvas 画一条鱼?

问题描述

我正在尝试使用 tkinter 定义的 Canvas 类在碗中画一条鱼。我画了一个立方体,工作完成了 50%,但我需要帮助来画碗里的鱼。如何使用 Tkinter Canvas 画一条鱼?请帮帮我!

这就是我想要实现的

关联

这是我的代码:


from tkinter import *
root = Tk()
root.title('graphics')

canv = Canvas(root, width = 800, height = 800, bg = "white", cursor = "pencil")

canv.create_line(150, 250, 450, 250, width = 2, fill = "black")
canv.create_line(150, 550, 450, 550, width = 2, fill = "black")
canv.create_line(150, 250, 150, 550, width = 2, fill = "black")
canv.create_line(450, 250, 450, 550, width = 2, fill = "black")

canv.create_line(300, 150, 600, 150, width = 2, fill = "black")
canv.create_line(300, 450, 600, 450, width = 2, fill = "black")
canv.create_line(300, 150, 300, 450, width = 2, fill = "black")
canv.create_line(600, 150, 600, 450, width = 2, fill = "black")

canv.create_line(150, 250, 300, 150, width = 2, fill = "black")
canv.create_line(450, 250, 600, 150, width = 2, fill = "black")
canv.create_line(150, 550, 300, 450, width = 2, fill = "black")
canv.create_line(450, 550, 600, 450, width = 2, fill = "black")

canv.create_line(150, 300, 300, 200, width = 2, fill = "black")
canv.create_line(450, 300, 600, 200, width = 2, fill = "black")
canv.create_line(150, 300, 450, 300, width = 2, fill = "black")
canv.create_line(300, 200, 600, 200, width = 2, fill = "black")

canv.pack()
root.mainloop()

标签: pythontkintertkinter-canvas

解决方案


推荐阅读