Android QPython3 SL4A 常用函數(shù):Dialog.py
#需要android.py??https://www.bilibili.com/read/cv8679914
from android import droid,rsla,jsla
OK=('OK',)
YN=('Yes','No')
OC=('OK','Cancel')
YNC=('Yes','No','Cancel')
PNNS={'positive':1,'negative':-1,'neutral':0}
PNNt=tuple(PNNS)
def Which():#請忽略
? ? return PNNS[rsla("dialogGetResponse")['which']]
def ButtonText(button):#請忽略
? ? Lc=len(button)
? ? if Lc>2:jsla("dialogSetNeutralButtonText",button[2])
? ? if Lc>1:jsla("dialogSetNegativeButtonText",button[1])
? ? if Lc==0:button=OK
? ? jsla("dialogSetPositiveButtonText",button[0])
def Button(title='Prompt',message='Are you sure ?',button=YNC):#三鍵按鈕
? ? jsla("dialogCreateAlert",title, message)
? ? ButtonText(button)
? ? jsla("dialogShow")
? ? try:
? ? ? ? return Which()
? ? except:
? ? ? ? return 0
def ProgressCreate(title='標題',message='內(nèi)容', maxValue=100):#創(chuàng)建進度條
? ? jsla("dialogCreateHorizontalProgress",title,message,maxValue)
? ? jsla("dialogShow")
def ProgressSet(CurrentValue):#設置進度條當前值
? ? jsla('dialogSetCurrentProgress',CurrentValue)
def Progressmax(MaxValue):#設置進度條最大值
? ? jsla('dialogSetMaxProgress',MaxValue)
def ProgressDis():#關閉進度條
? ? jsla('dialogDismiss')
def SeekBar(Start=50,Max=100,Title='標題',Message='內(nèi)容',button=OC):#拖動條
? ? jsla("dialogCreateSeekBar",Start,Max,Title,"%s\n\n0 ~ %s"%(Message,Max))
? ? jsla("dialogSetPositiveButtonText",button[0])
? ? jsla("dialogSetNegativeButtonText",button[1])
? ? jsla("dialogShow")
? ? r=rsla("dialogGetResponse")
? ? try:
? ? ? ? if r['which']=='positive':
? ? ? ? ? ? return r['progress']
? ? except:
? ? ? ? pass
def SpinCreate(title='標題',message='內(nèi)容'):#創(chuàng)建轉圈
? jsla("dialogCreateSpinnerProgress",title, message)
? jsla("dialogShow")
SpinDis=ProgressDis#清除轉圈
def Login(title='Login',message=('Username','Password')):#登錄窗口
? ? u=rsla("dialogGetInput",title,message[0])
? ? if not u:
? ? ? ? return None,None
? ? p=rsla("dialogGetPassword",title,message[1])
? ? if not p:
? ? ? ? return None,None
? ? return u,p
def List(title='Which is your choose ?',list_=YNC):#列表選項
? ? jsla("dialogCreateAlert",title)
? ? jsla("dialogSetItems",list_)
? ? jsla("dialogShow")
? ? try:
? ? ? ? return rsla("dialogGetResponse")['item']
? ? except:
? ? ? ? return None
def Input(title="Value",message="Please enter a value :",default=""):#單行輸入窗口
? ? return rsla("dialogGetInput",title,message,default)
def Password(title="Password",message="Please enter password:"):#密碼輸入窗口
? ? return rsla("dialogGetPassword",title,message)
def setClip(Text):#設置剪貼板內(nèi)容
? ? jsla('setClipboard',Text)
def getClip():#獲取剪貼板內(nèi)容
? ? return rsla("getClipboard")
def Vibrate(millisecond=250):#振動
? ? jsla('vibrate',millisecond)
def Notify(title,message):#通知欄提示
? ? jsla('notify',title,message)
def Toast(message):#吐司提示框
? ? jsla('makeToast',message)
def Speak(message):#文字轉語音
? ? jsla('ttsSpeak',message)
作者:乘著船@Bilibili
更多文章+下載鏈接:https://www.bilibili.com/read/readlist/rl321663