以下是部分代码预览:
"""本程序实现一个温度计模拟,需要thermometer支持,模块在下面
from thermometer import *
"""自定义形坐标点,不采用内置的square的原因是它以中心点为旋转中心,
页这个是以最下边中心点为旋转中心,所以伸长的时候不会向两边伸长。"""
width,height = 300,840
screen = Screen() # 新建屏幕对象
screen.colormode(255) # 颜色模式为RGB255
screen.setup(width,height) # 设定屏幕的宽和高
screen.delay(0) # 设定绘画延时
screen.addshape("mysquare",p) # 注册 mysquare 形状
screen.addshape("ball-red.gif") # 注册gif图
screen.addshape("ball-cyan.gif")
screen.addshape("sun.gif")
screen.addshape("snow.gif")
screen.addshape("button1+.gif")
screen.addshape("button1-.gif")
screen.bgpic("背景短空.png")
"新建温度计对象,参数为初始温度"
temperature = 60
therm = Thermometer(temperature) # 接受整型参数,-28到80之间
therm.shape("mysquare") # 设定形状为mysquare
button_add = Button("button1+.gif",100,-350,therm,"+")
button_sub = Button("button1-.gif",-100,-350,therm,"-")
screen.listen() # 设置焦点,监听键盘
screen.mainloop() # 刷新组件,进入主循环
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

