tkinter库绘图实例6:弧线绘制

实例代码

import tkinter as tk                    # 导入tkinter库,并重命名为tk
mywindow = tk.Tk()                      # 创建一个窗体
mywindow.title("绘制弧线")              # 设置窗体的标题
# 创建画布并布局
mycanvas = tk.Canvas(mywindow,width=250,height=250,bg="white")
mycanvas.pack()

# 绘制扇形
mypie1 = mycanvas.create_arc(10,10,100,100)
mypie2 = mycanvas.create_arc(120,10,220,100,start=10,extent=120,width=3,fill="purple",outline="red")

# 绘制弓形
mych1 = mycanvas.create_arc(10,100,100,200,style="chord")
mych2 = mycanvas.create_arc(120,100,200,200,style="chord",extent=100,width=3,fill="purple",outline="red")

# 绘制弧线
myarc1 =mycanvas.create_arc(10,180,100,260,style="arc")
myarc2 =mycanvas.create_arc(100,180,200,260,style="arc",start=10,extent=120,width=6,outline="red")

mywindow.mainloop()      # 显示画布

运行结果

tkinter库绘图实例6:弧线绘制_第1张图片 

你可能感兴趣的:(Python,tkinter,绘图)