用python的tkinker库画一条龙
时间: 2024-01-26 16:46:18 浏览: 94
好的,以下是用Python的tkinter库画一条龙的代码:
```python
from tkinter import *
# 创建画布
canvas_width = 500
canvas_height = 500
master = Tk()
canvas = Canvas(master, width=canvas_width, height=canvas_height)
canvas.pack()
# 画龙
canvas.create_line(50, 250, 100, 250, fill="black", width=3)
canvas.create_line(100, 250, 120, 230, fill="black", width=3)
canvas.create_line(120, 230, 200, 230, fill="black", width=3)
canvas.create_line(200, 230, 220, 250, fill="black", width=3)
canvas.create_line(220, 250, 250, 250, fill="black", width=3)
canvas.create_line(250, 250, 270, 230, fill="black", width=3)
canvas.create_line(270, 230, 350, 230, fill="black", width=3)
canvas.create_line(350, 230, 370, 250, fill="black", width=3)
canvas.create_line(370, 250, 420, 250, fill="black", width=3)
# 显示画布
mainloop()
```
希望能帮到你!
阅读全文