前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python canvas画布

python canvas画布

作者头像
用户5760343
发布2022-05-13 10:44:16
1.4K0
发布2022-05-13 10:44:16
举报
文章被收录于专栏:sktj

image.png

"demo all basic canvas interfaces"

from tkinter import *

canvas = Canvas(width=525, height=300, bg='white') # 0,0 is top left corner canvas.pack(expand=YES, fill=BOTH) # increases down, right

canvas.create_line(100, 100, 200, 200) # fromX, fromY, toX, toY canvas.create_line(100, 200, 200, 300) # draw shapes for i in range(1, 20, 2): canvas.create_line(0, i, 50, i)

canvas.create_oval(10, 10, 200, 200, width=2, fill='blue') canvas.create_arc(200, 200, 300, 100) canvas.create_rectangle(200, 200, 300, 300, width=5, fill='red') canvas.create_line(0, 300, 150, 150, width=10, fill='green')

photo=PhotoImage(file='../gifs/ora-lp4e.gif') canvas.create_image(325, 25, image=photo, anchor=NW) # embed a photo

widget = Label(canvas, text='Spam', fg='white', bg='black') widget.pack() canvas.create_window(100, 100, window=widget) # embed a widget canvas.create_text(100, 280, text='Ham') # draw some text mainloop()

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-05-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档