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

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

Android QPython3 可視化-文件(夾)選擇:RadioFile.py

2020-09-18 19:59 作者:乘著船  | 我要投稿

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


from BaseWindow import *

from os import listdir

from os.path import isdir

RB="""

<RadioButton

? ? android:id="@+id/Radio%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="#3f7faf"

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">

? ? <TextView

android:id="@+id/Title"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:textSize="9dp"

android:text="%s"

android:textColor="#ffffff"

android:textStyle="bold"

android:layout_weight="1"

android:gravity="center"

/>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:textSize="6dp"

android:text="當(dāng)前文件夾路徑:%s"

android:textColor="#ffffff"

android:layout_weight="1"/>

? ? <RadioGroup

? ? ? ? android:id="@+id/RadioGroup"

? ? ? ? android:layout_width="fill_parent"

? ? ? ? android:layout_height="fill_parent"

? ? ? ? android:orientation="vertical">

""","""

? ? </RadioGroup>

</LinearLayout>

</ScrollView>

? ? </LinearLayout>

? ? <LinearLayout

android:layout_width="fill_parent"

android:layout_height="160dp"

android:orientation="vertical"

android:layout_weight="10">

? ? <LinearLayout

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="horizontal"

android:layout_weight="8">

? ? <TextView

android:layout_width="wrap_content"

android:layout_height="fill_parent"

android:textSize="6dp"

android:text="文件名"

android:textColor="#ffffff"

android:background="#af3f3f"

android:layout_weight="1"

/>

? ? <EditText

android:id="@+id/FileName"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:textSize="6dp"

android:text="%s"

android:textColor="#0000ff"

android:layout_weight="4"

/>

</LinearLayout>

? ? <LinearLayout

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="horizontal"

android:layout_weight="8">

<Button

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="確認(rèn)"

android:id="@+id/but_conf"

android:textSize="6dp"

android:background="#007f0f"

android:textColor="#ffffff"

android:layout_weight="1"

android:gravity="center"/>

<Button

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="向上"

android:id="@+id/but_uppt"

android:textSize="6dp"

android:background="#6f1f00"

android:textColor="#ffffff"

android:layout_weight="1"

android:gravity="center"/>

<Button

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="初始"

android:id="@+id/but_strt"

android:textSize="6dp"

android:background="#2f005f"

android:textColor="#ffffff"

android:layout_weight="1"

android:gravity="center"/>

<Button

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="取消"

android:id="@+id/but_canc"

android:textSize="6dp"

android:background="#4f3f00"

android:textColor="#ffffff"

android:layout_weight="1"

android:gravity="center"/>

</LinearLayout>

? ? </LinearLayout>

</LinearLayout>"""

class MainScreen(Layout):

? ? def on_show(self):

? ? ? ? v=self.views

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

? ? ? ? ? ? c=v['Radio%s'%i]

? ? ? ? ? ? c.add_event(click_EventHandler(c,self.clck))

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

? ? ? ? v.but_uppt.add_event(click_EventHandler(v.but_uppt,self.uppt))

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

? ? ? ? v.but_strt.add_event(click_EventHandler(v.but_strt,self.strt))

? ? def on_close(self):

? ? ? ? pass

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

? ? ? ? x=int(dummy['data']['id'][5:])

? ? ? ? if x<self.DirCount:

? ? ? ? ? ? d=self.Dir[x]

? ? ? ? ? ? MainScreen.Path=(d,self.views.FileName.text)

? ? ? ? else:

? ? ? ? ? ? d=self.File[x-self.DirCount]

? ? ? ? ? ? x=d.rfind('/')

? ? ? ? ? ? if x>=0:

? ? ? ? ? ? ? ? d=d[x+1:]

? ? ? ? ? ? MainScreen.Path=(MainScreen.Path,d)

? ? ? ? FullScreenWrapper2App.close_layout()

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

? ? ? ? MainScreen.Path=self.Path+self.views.FileName.text

? ? ? ? FullScreenWrapper2App.close_layout()

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

? ? ? ? MainScreen.Path=(PathUp(self.Path),self.views.FileName.text)

? ? ? ? FullScreenWrapper2App.close_layout()

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

? ? ? ? MainScreen.Path=None

? ? ? ? FullScreenWrapper2App.close_layout()

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

? ? ? ? MainScreen.Path=(MainScreen.sPath,self.views.FileName.text)

? ? ? ? FullScreenWrapper2App.close_layout()

cmColor=('3f3f7f','7f007f')

def RadioFile(Title='選擇一個文件(夾)',Path='/sdcard',FileName=''):#主函數(shù)

#文件(夾)選擇器(標(biāo)題,初始路徑,初始文件名)

#按圓形按鈕項:進入對應(yīng)路徑,或選擇對應(yīng)文件

#按“確認(rèn)”:返回文件(夾)路徑

#按“取消”:返回None

#按“向上”:進入上級路徑

#按“初始”:重回Path路徑

? ? MainScreen.sPath=d=MainScreen.Path=PathStrip(Path)

? ? while True:

? ? ? ? try:

? ? ? ? ? ? l=listdir(d)

? ? ? ? except:

? ? ? ? ? ? l=[]

? ? ? ? MainScreen.Dir=D=[]

? ? ? ? MainScreen.File=F=[]

? ? ? ? l.sort()

? ? ? ? for i in l:

? ? ? ? ? ? j=d+i

? ? ? ? ? ? if isdir(j):

? ? ? ? ? ? ? ? D.append(j+'/')

? ? ? ? ? ? else:

? ? ? ? ? ? ? ? F.append(j)

? ? ? ? b=[]

? ? ? ? for i in D:

? ? ? ? ? ? b.append(i.rsplit('/',2)[-2]+':目錄')

? ? ? ? for i in F:

? ? ? ? ? ? b.append(i.rsplit('/',1)[-1]+':文件')

? ? ? ? MainScreen.Count=l=len(b)

? ? ? ? MainScreen.DirCount=len(D)

? ? ? ? r=[XML[0]%(Str2Xml(Title),Str2Xml(d))]

? ? ? ? i=-1

? ? ? ? for i in range(l):

? ? ? ? ? ? r.append(RB%(i,Str2Xml(b[i]),cmColor[i%2]))

? ? ? ? r.append(XML[1]%Str2Xml(FileName))

? ? ? ? r=''.join(r)

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

? ? ? ? FullScreenWrapper2App.eventloop()

? ? ? ? d=MainScreen.Path

? ? ? ? if d==None:

? ? ? ? ? ? return

? ? ? ? elif type(d)!=tuple:

? ? ? ? ? ? return d

? ? ? ? d,FileName=d

? ? ? ? MainScreen.Path=d

def PathUp(x):

? ? y=x.rfind('/',0,-1)

? ? return x[:y+1]

def PathStrip(Path):

? ? Path=Path.strip()

? ? if Path=='' or Path[-1]!='/':

? ? ? ? Path+='/'

? ? return Path

__all__=('RadioFile','droid')


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



RadioFile('標(biāo)題','/sdcard/qpython','xx.py')

按“確認(rèn)”返回:'/sdcard/qpython/xx.py'


作者:乘著船@Bilibili

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



Android QPython3 可視化-文件(夾)選擇:RadioFile.py的評論 (共 條)

使用qq登录你需要登录后才可以评论。
福泉市| 鹿泉市| 乐都县| 开江县| 泽州县| 通榆县| 成武县| 安庆市| 同心县| 南和县| 宜兰县| 禄劝| 富川| 南华县| 资阳市| 都匀市| 凌源市| 高雄县| 伽师县| 安塞县| 阳西县| 长兴县| 上饶县| 新宁县| 扬州市| 远安县| 香河县| 金沙县| 梁山县| 罗城| 金溪县| 即墨市| 洛宁县| 定兴县| 眉山市| 龙江县| 兰溪市| 鄂尔多斯市| 剑川县| 大庆市| 科尔|