猫史档案馆


【Python作品分享】tkinter绘制图形

用户:tryagain1tryagain1查看:0 回复:0 评论:0 创建时间:2021-10-19T10:43:38


【作品展示】

center_image

 

【作品介绍】

GUI界面的绘制

 

【作品源代码】

from tkinter import *
root=Tk()
# 界面大小300x300
root.geometry('300x300')
# 在界面中画出一个200*200的画布,画布颜色白色
cv=Canvas(root,bg='white',width=200,height=200)
 
# 在画布中画出一个矩形,fill为矩形填充的颜色,outline边界颜色且width宽度
cv.create_rectangle(50,50,150,150,fill='blue',outline='green',width=2)
#在矩形中在画出一个矩形,dash为虚线
cv.create_rectangle(80,80,120,120,fill='black',outline='purple',dash=10)
#stipple看似网格
rt=cv.create_rectangle(0,0,50,50,fill='black',outline='purple',stipple='gray12')
cv.pack()
#coords将某部分移动到另一区域
cv.coords(rt,0,150,200,200)
root.mainloop()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页