当前位置:网站首页>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()
边栏推荐
猜你喜欢
二叉树的搜索与回溯问题(leetcode)
loadrunner-controller-目标场景Schedule配置
VMware下安装win10启动后进入Boot Manger界面如何解决
服务器上解压文件时提示“gzip: stdin: not in gzip format,tar: Child returned status 1,tar: Error is not recovera“
Redis Sentinel原理
(C语言)程序环境和预处理
Binary tree search and backtracking problem (leetcode)
Kotlin入门介绍篇
【机器学习】用特征量重要度(feature importance)解释模型靠谱么?怎么才能算出更靠谱的重要度?
loadrunner-controller-场景执行run
随机推荐
qt在不同的线程中传递自定义结构体参数
PyQt5快速开发与实战 9.4 Matplotlib在PyQt中的应用
利用frp服务器进行内网穿透ssh访问
数据中台建设(六):数据体系建设
Redis集群-哨兵模式原理(Sentinel)
【RISC-V】risc-v架构学习笔记(架构初学)
【TCP/IP】Network Model
【Excel】生成随机数字/字符
js实现2020年元旦倒计时公告牌
js以变量为键
Progressive Web App(PWA)
&#x开头的是什么编码?
Pytorch学习记录(七):自定义模型 & Auto-Encoders
状态机动态规划之股票问题总结
djangoWeb应用框架+MySQL数据4
Andoird开发--指南针(基于手机传感器)
js部门预算和支出雷达图
VMware下安装win10
loadrunner-controller-场景执行run
spark过滤器