当前位置:网站首页>使用turtle画按钮
使用turtle画按钮
2022-07-31 09:21:00 【东方金木】
#
import turtle as t
# 获取当前屏幕
src=t.getscreen()
# src.setup(480,360)
# src.delay(0)
def goto_s(ct,x,y):
ct.penup()
ct.goto(x,y)
ct.pendown()
# 获取当前鼠标位置
def cursor_x_y(event):
# 判断鼠标范围是不是在按钮上就要将按钮进行和原来的坐标进行转换
# 获得当前屏幕大小计算自己的位置
# src=t.getscreen()
# print(src.screensize())
print(src.canvheight)
print(event.x)
print(event.y)
# 参数
height=20
width=40
width-=height
r=height//2
if height%2!=0:
print("不可")
if width==0:
print("按钮是个圆")
out_line_color="red"
button_color="yellow"
x=10
y=10
# 自定义形状
goto_s(t,x,y)
t.hideturtle()
t.speed(100)
t.color(out_line_color,button_color)
t.begin_fill()
t.circle(r,180)
t.forward(width)
t.circle(r,180)
t.forward(width)
t.end_fill()
src.cv.bind("<Motion>",cursor_x_y)
# 顺时针旋转60°
t.done()
边栏推荐
猜你喜欢
随机推荐
Linux 创建mysql数据库并创建账号密码
内联元素居中
编译器R8问题Multidex
MySQL 排序
matlab常用符号用法总结
spark过滤器
Mysql+Navicat for Mysql
Redis集群-哨兵模式原理(Sentinel)
一次Spark SQL线上问题排查和定位
搭建frp进行内网穿透
利用frp服务器进行内网穿透ssh访问
&#x开头的是什么编码?
A Spark SQL online problem troubleshooting and positioning
我的创作纪念日
Job hunting product manager [9] How to write a good resume in job hunting season?
loadrunner录制问题
【Excel】生成随机数字/字符
关于挂载EXfat文件格式U盘失败的问题
来n遍剑指--05. 替换空格
qt pass custom structure parameters in different threads