第11章 Tkinter Canvas

绘制几何图形方法create_linecreate_rectanglecreate_ovalcreate_arccreate_polygon图形直线矩形椭圆弧多边形坐标点起点 + 终点左上角 + 右下角所有点椭圆为同坐标点矩形的内切椭圆,弧为椭圆的一部分通用参数通用参数filloutlinewidthdashstipple含义填充颜色边框颜色边框宽度虚线边框用位图填充dash中,单个整数表示
摘要由CSDN通过智能技术生成

绘制几何图形

方法 create_line create_rectangle create_oval create_arc create_polygon
图形 直线 矩形 椭圆 多边形
坐标点 起点 + 终点 左上角 + 右下角 所有点
  • 椭圆为同坐标点矩形的内切椭圆,弧为椭圆的一部分

通用参数

通用参数 fill outline width dash stipple
含义 填充颜色 边框颜色 边框宽度 虚线边框 用位图填充
  • dash中,单个整数表示实线的长度,多个整数中,奇数位表实线长度,偶数位表间隔长度
a = Canvas(win)
a.pack()

p = (10, 10, 100, 100)
a.create_line(p, dash=(10,20,30,40))
a.create_rectangle(p, fill='blue', stipple='questhead')
a.create_oval(p, outline='blue')
a.create_arc(p, width=3)
a.create_polygon(0, 0, 0, 100, 100, 100)

在这里插入图片描述

专属参数

分类 参数 含义 说明
直线 arrow 两端是否有箭头 NONE, FIRST, LAST, BOTH
arrowshap 箭头形状 3个整数依次为填充长度、箭头长、宽
joinstyle 拐角造型 尖MITER,圆ROUND,平BEVEL
start 起始角度 默认值为0,3点钟方向
extent 逆时针转过的角度 默认值为90
style 样式(默认为扇形) 扇形PIESLICE,弓形CHORD,弧形ARC
a.create_line(p, arrow=FIRST, arrowshap=(10,20,30))
a.create_line(p, 10, 100, width=10, joinstyle=BEVEL)
a.create_arc(p, style=ARC)
a.create_arc(p, style=CHORD)
a.create_arc(p, start=90, extent=180)

在这里插入图片描述

绘制其它图形

只需要一个坐标点

方法 create_text create_bitmap create_image create_window
绘制内容 文本 位图 图像 组件

绘制文本 create_text

参数 text width fill font anchor justify
含义 文本 宽度 字体颜色 字体格式 对齐方式 多行文本对齐方式
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ailsa2019

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值