当前位置:网站首页>使用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()
边栏推荐
猜你喜欢
随机推荐
js以变量为键
JS中原型和原型链的详细讲解(附代码示例)以及 new关键字具体做了什么的详细讲解
SQL join table (inner join, left join, right join, cross join, full outer join)
手写promise
djangoWeb应用框架+MySQL数据4
PyQt5快速开发与实战 9.4 Matplotlib在PyQt中的应用
Come n times - 06. Print the linked list from end to end
Kotlin 优点
关于挂载EXfat文件格式U盘失败的问题
MUI获取相机权限
A brief introduction to the SSM framework
loadrunner-controller-目标场景Schedule配置
【Redis高手修炼之路】Jedis——Jedis的基本使用
Redis集群-哨兵模式原理(Sentinel)
VMware下安装win10启动后进入Boot Manger界面如何解决
高并发高可用高性能的解决方案
[NLP] Interpretation of Transformer Theory
搭建frp进行内网穿透
JSP page对象简介说明
一次Spark SQL线上问题排查和定位









