python tkinter canvas使用实例

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

python tkinter canvas使用实例

  2021-04-02 我要评论

这篇文章主要介绍了python tkinter canvas使用实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

注:在使用 create_arc 绘制弧时,和 create_oval 的用法相似,因为弧是椭圆的一部分,因此同样也是指定左上角和右下角两个点的坐标。

默认总是绘制从 (x_1,y_1)开始,程序可通过 start 改变起始角度,也可通过 extent 改变转过的角度(逆时针旋转)。

from tkinter
import *
root = Tk()
root.title('Wjz')
cv = Canvas(root, background = 'white',
	width = 200, height = 200)
cv.pack(fill = BOTH, expand = YES)
# 绘制左上角半圆
cv.create_arc((5, 5, 85, 85),
	width = 2,
	outline = "red",
	start = 0,
	extent = 180,
	style = ARC)# 绘制右上角半圆
cv.create_arc((85, 5, 165, 85),
	width = 2,
	outline = "red",
	start = 0,
	extent = 180,
	style = ARC)# 绘制下方半圆
cv.create_arc((5, -45, 165, 125),
	width = 2,
	outline = "red",
	start = 180,
	extent = 180,
	style = ARC)
root.mainloop()

代码执行结果:

您可能感兴趣的文章:

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们