当前位置:网站首页>Use turtle to draw buttons
Use turtle to draw buttons
2022-07-31 09:32:00 【Oriental Golden Wood】
#
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):
# To determine whether the mouse range is on the button, it is necessary to convert the button to the original coordinates
# Get the current screen size to calculate your own position
# 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("button is a circle")
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()
边栏推荐
猜你喜欢
随机推荐
A Spark SQL online problem troubleshooting and positioning
第二十二课,实例化(instancing)
loadrunner-controller-目标场景Schedule配置
【软考软件评测师】2012综合知识历年真题
【NLP】Transformer理论解读
JSP response,request操作中(中文乱码)-如何解决呢?
Kotlin—基本语法 (五)
模块八
多个js雷达图同时显示
JS中原型和原型链的详细讲解(附代码示例)以及 new关键字具体做了什么的详细讲解
MySQL 视图(详解)
Mysql+Navicat for Mysql
(selenium)Service geckodriver unexpectedly exited. Status code was: 64
踩水坑2 数据超出long long
qt在不同的线程中传递自定义结构体参数
如何将虚拟机上的文件复制到主机上
Gradle系列——Groovy概述,基础使用(基于Groovy文档4.0.4)day2-1
Linux 创建mysql数据库并创建账号密码
如何在 TiDB Cloud 上使用 Databricks 进行数据分析 | TiDB Cloud 使用指南
Kotlin 优点