2686浏览
查看: 2686|回复: 0

行空板触摸屏(1)

[复制链接]
画板
#  -*- coding: UTF-8 -*-

# MindPlus
# Python
from pinpong.extension.unihiker import *
from pinpong.board import Board,Pin
from unihiker import GUI

# 事件回调函数
def button_click1():
    buzzer.play(buzzer.ENTERTAINER,buzzer.ForeverInBackground)
def button_click2():
    buzzer.stop()
def button_click3():
    a=u_gui.draw_emoji(emoji="Angry",x=0,y=0,duration=0.2)
def mouse_move(x,y):
    global my_variable
    global aaa
    global bbb
    if (my_variable == 0):
        a=u_gui.draw_rect(x=x,y=y,w=1,h=1,width=1,color="#0000FF")
        aaa = x
        bbb = y
        my_variable = 1
    else:
        a=u_gui.draw_line(x0=aaa,y0=bbb,x1=x,y1=y,width=1,color="#0000FF")
        aaa = x
        bbb = y
def on_buttona_click_callback():
    u_gui.fill_rect(x=0,y=0,w=240,h=240,color="#FFFFFF")
    a=u_gui.draw_line(x0=0,y0=240,x1=240,y1=240,width=2,color="#000000")
def on_buttonb_click_callback():
    print(requests.post("http://713b2462d056429b93195bfb0accf468-cn-shanghai.alicloudapi.com", data={'node_8dd82d30': 0,'aaa':1}))


u_gui=GUI()
Board().begin()
u_gui.on_mouse_move(mouse_move)
u_gui.on_a_click(on_buttona_click_callback)
u_gui.on_b_click(on_buttonb_click_callback)
import requests
my_variable = 0
aaa = 0
bbb = 0
a=u_gui.draw_line(x0=0,y0=240,x1=240,y1=240,width=2,color="#000000")
a=u_gui.add_button(text="开始",x=100,y=250,w=40,h=30,onclick=button_click1)
a=u_gui.add_button(text="停止",x=150,y=250,w=40,h=30,onclick=button_click2)
a=u_gui.add_button(text="不要按",x=55,y=250,w=40,h=30,onclick=button_click3)
buzzer.stop()

while True:
    pass
下载附件cache-file.py.rar





您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail