最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Android QPython3 可視化-多選:CheckGroup.py

2020-09-16 22:07 作者:乘著船  | 我要投稿

#需要BaseWindow.py??https://www.bilibili.com/read/cv8680125


from BaseWindow import *

CB="""

<CheckBox

? ? android:id="@+id/Check%s"

? ? android:layout_width="fill_parent"

? ? android:layout_height="wrap_content"

? ? android:textSize="8dp"

? ? android:text="%s"

? ? android:background="#%s"

/>

"""

XML="""<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="#4f3f2f"

android:orientation="vertical"

xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical"

android:layout_weight="20">

<ScrollView? ?

? ? ? ? android:layout_width="fill_parent"? ?

? ? ? ? android:layout_height="fill_parent" >?

<LinearLayout

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical"

android:layout_weight="20">

? ? <EditText

android:id="@+id/Title"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:textSize="8dp"

android:text="%s"

android:textColor="#ff0000"

android:layout_weight="1"

android:gravity="center"

/>

""","""

</LinearLayout>

</ScrollView>

? ? </LinearLayout>

<LinearLayout

android:layout_width="fill_parent"

android:layout_height="100dp"

android:orientation="horizontal"

android:layout_weight="8">

<Button

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="%s"

android:id="@+id/but_conf"

android:textSize="6dp"

android:background="#007f7f"

android:textColor="#ffffffff"

android:layout_weight="1"

android:gravity="center"/>

<Button

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="%s"

android:id="@+id/but_copy"

android:textSize="6dp"

android:background="#7f7f00"

android:textColor="#ffffffff"

android:layout_weight="1"

android:gravity="center"/>

<Button

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="%s"

android:id="@+id/but_canc"

android:textSize="6dp"

android:background="#7f007f"

android:textColor="#ffffffff"

android:layout_weight="1"

android:gravity="center"/>

<Button

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="加載中…"

android:id="@+id/but_alno"

android:textSize="6dp"

android:background="#3f3f3f"

android:textColor="#ffffffff"

android:layout_weight="1"

android:gravity="center"/>

</LinearLayout>

</LinearLayout>"""

def getCheck(self):

? ? j=[]

? ? C=self.Check

? ? c=self.check

? ? for i in range(self.Count):

? ? ? ? if c[i].checked=='true':

? ? ? ? ? ? if C:

? ? ? ? ? ? ? ? j.append(C[i])

? ? ? ? ? ? else:

? ? ? ? ? ? ? ? j.append(i)

? ? return j

class MainScreen(Layout):

? ? def on_show(self):

? ? ? ? v=self.views

? ? ? ? Check=[]

? ? ? ? for i in range(self.Count):

? ? ? ? ? ? Check.append(v.pop('Check%s'%i))

? ? ? ? self.check=Check

? ? ? ? v.but_alno.text=self.AlNo[0]

? ? ? ? v.but_conf.add_event(click_EventHandler(v.but_conf,self.conf))

? ? ? ? v.but_copy.add_event(click_EventHandler(v.but_copy,self.copy))

? ? ? ? v.but_alno.add_event(click_EventHandler(v.but_alno,self.alno))

? ? ? ? v.but_canc.add_event(click_EventHandler(v.but_canc,self.canc))

? ? def on_close(self):

? ? ? ? pass

? ? def copy(self,view,dummy):

? ? ? ? droid.setClipboard(str(getCheck(self)))

? ? def alno(self,view,dummy):

? ? ? ? if self.views.but_alno.text==self.AlNo[0]:

? ? ? ? ? ? a=self.AlNo[1];b='true'

? ? ? ? else:

? ? ? ? ? ? a=self.AlNo[0];b='false'

? ? ? ? self.views.but_alno.text=a

? ? ? ? c=self.check

? ? ? ? for i in range(self.Count):

? ? ? ? ? ? c[i].checked=b

? ? def conf(self,view,dummy):

? ? ? ? MainScreen.Text=getCheck(self)

? ? ? ? FullScreenWrapper2App.close_layout()

? ? def canc(self,view,dummy):

? ? ? ? MainScreen.Text=None

? ? ? ? FullScreenWrapper2App.close_layout()

ALNO=('全選','全不選')

rcColor=('7f3f3f','3f3f7f')

def CheckGroup(Title='',Check=(),returnValue=False,ycnButton=CCC,anButton=ALNO):#主函數(shù)

#復(fù)選按鈕組(標(biāo)題,復(fù)選按鈕文本組(按鈕1,按鈕2,……),返回?cái)?shù)值,(確認(rèn)按鈕文本,復(fù)制按鈕文本,取消按鈕文本),(全選按鈕文本,全不選按鈕文本))

#返回:[選擇內(nèi)容的list列表];如果不選按確定,返回空列表[];如果取消,返回None。

#返回?cái)?shù)值(returnValue)為True,返回實(shí)際值;返回?cái)?shù)值(returnValue)為False,返回序號。

? ? r=[XML[0]%Str2Xml(Title)];i=-1

? ? for i in range(len(Check)):

? ? ? ? r.append(CB%(i,Str2Xml(Check[i]),rcColor[i%2]))

? ? MainScreen.Count=i+1

? ? if returnValue:

? ? ? ? MainScreen.Check=Check

? ? else:

? ? ? ? MainScreen.Check=False

? ? r.append(XML[1]%tuple(ycnButton))

? ? r=''.join(r)

? ? MainScreen.AlNo=anButton

? ? FullScreenWrapper2App.show_layout(MainScreen(r,'Check'))

? ? FullScreenWrapper2App.eventloop()

? ? r=MainScreen.Text

? ? del MainScreen.Text,MainScreen.AlNo

? ? return r

__all__=('CheckGroup','droid')


==========說明==========


CheckGroup('問題',('答案1','答案2','答案3'),False,('確定','復(fù)制','取消'),('全對','全錯(cuò)'))

此時(shí)如果按“確定”,返回:[],

此時(shí)如果按下“全對”按鈕,

CheckGroup('問題',('答案1','答案2','答案3'),False,('確定','復(fù)制','取消'),('全對','全錯(cuò)'))

此時(shí)如果按“確定”,返回:[0,1,2],

如果returnValue=True,返回['答案1','答案2','答案3']。

作者:乘著船@Bilibili

更多文章+下載鏈接:https://www.bilibili.com/read/readlist/rl321663



Android QPython3 可視化-多選:CheckGroup.py的評論 (共 條)

分享到微博請遵守國家法律
嵊泗县| 固镇县| 镇江市| 蛟河市| 密山市| 驻马店市| 西贡区| 陇川县| 红桥区| 若尔盖县| 崇信县| 东阿县| 循化| 镇宁| 葫芦岛市| 前郭尔| 镇原县| 桑日县| 遂溪县| 东兴市| 蕉岭县| 金溪县| 彭阳县| 留坝县| 汤原县| 漳州市| 金门县| 措美县| 唐山市| 南投市| 吉水县| 松溪县| 上虞市| 苗栗市| 凉山| 江油市| 依兰县| 塔河县| 兴宁市| 三门峡市| 阜新市|