#  -*- coding: UTF-8 -*-

# MindPlus
# Python
from unihiker import Audio
from unihiker import GUI

# 事件回调函数
def button_click1():
    thread1=u_gui.start_thread(u_thread1_function)
def button_click2():
    thread2=u_gui.start_thread(u_thread2_function)
def u_thread1_function():
    global BianHao
    BianHao = (BianHao + 1)
    bofang.config(image="play.png")
    u_audio.start_play("ZSJ.mp3")
    u_audio.record((str(BianHao) + str("record.wav")),50)
    u_audio.stop_play()
    bofang.config(image="wait.png")
def u_thread2_function():
    global BianHao
    BianHao = (BianHao + 1)
    bofang.config(image="play.png")
    u_audio.start_play("XYT.mp3")
    u_audio.record((str(BianHao) + str("record.wav")),50)
    u_audio.stop_play()
    bofang.config(image="wait.png")
def button_click3():
    bofang.config(image="play.png")
    u_audio.start_play((str(BianHao) + str("record.wav")))
def button_click4():
    bofang.config(image="wait.png")
    u_audio.pause_play()


u_gui=GUI()
u_audio = Audio()
# 设置全局变量
global BianHao
BianHao = 0
# 屏幕界面设计
bg=u_gui.fill_rect(x=0,y=0,w=240,h=320,color="#000000")
icon=u_gui.draw_image(image="icon.png",x=0,y=20)
icon.config(w=30)
icon.config(h=30)
txt=u_gui.draw_text(text="伴奏列表",x=30,y=20,font_size=14, color="#FF6666")
xianduan=u_gui.draw_line(x0=2,y0=55,x1=120,y1=55,width=3,color="#FFFFFF")
xianduan=u_gui.draw_line(x0=2,y0=107,x1=239,y1=107,width=1,color="#FFFFFF")
xianduan=u_gui.draw_line(x0=2,y0=147,x1=239,y1=147,width=1,color="#FFFFFF")
anniu1=u_gui.draw_text(text="这世界那么多人",x=3,y=75,font_size=14, color="#9999FF")
anniu1.config(onclick=button_click1)
anniu2=u_gui.draw_text(text="逍遥叹",x=3,y=115,font_size=14, color="#9999FF")
anniu2.config(onclick=button_click2)
txt=u_gui.draw_text(text="点击歌曲，开始唱吧~",x=50,y=300,font_size=11, color="#FFFFFF")
bofang=u_gui.draw_image(image="wait.png",x=75,y=180)
bofang.config(w=80)
bofang.config(h=80)
PLAY=u_gui.add_button(text="播放",x=10,y=270,w=60,h=30,onclick=button_click3)
PAUSE=u_gui.add_button(text="暂停",x=180,y=270,w=60,h=30,onclick=button_click4)

while True:
    pass
