日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python安卓附带文件_Android QPython3 可视化-文件(夹)选择:ListFile.py

發布時間:2024/1/23 python 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python安卓附带文件_Android QPython3 可视化-文件(夹)选择:ListFile.py 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

#需要BaseWindow.py

from BaseWindow import *

from os import listdir

from os.path import isdir

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

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="#3faf7f"

android:orientation="vertical"

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

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical"

android:layout_weight="20">

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"

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:textSize="6dp"

android:text="當前文件夾路徑:%s"

android:textColor="#ffffff"

android:layout_weight="1"/>

android:id="@+id/listview"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_weight="20"

/>

android:layout_width="fill_parent"

android:layout_height="160dp"

android:orientation="vertical"

android:layout_weight="10">

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="horizontal"

android:layout_weight="8">

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"

/>

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"

/>

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="horizontal"

android:layout_weight="8">

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="確認"

android:id="@+id/but_conf"

android:textSize="6dp"

android:background="#3f7faf"

android:textColor="#ffffff"

android:layout_weight="1"

android:gravity="center"/>

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

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

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

"""

class MainScreen(Layout):

def on_show(self):

v=self.views

v.listview.set_listitems(self.List)

v.listview.add_event(itemclick_EventHandler(v.listview,self.clck))

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

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_strt.add_event(click_EventHandler(v.but_strt,self.strt))

def on_close(self):

pass

def clck(self,view,dummy):

x=int(dummy['data']['position'])

if x

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()

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

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

#按條形菜單項:進入對應路徑,或選擇對應文件

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

#按“取消”:返回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)

MainScreen.List=b=[]

for i in D:

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

for i in F:

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

MainScreen.Count=len(b)

MainScreen.DirCount=len(D)

r=XML%(Str2Xml(Title),Str2Xml(d),Str2Xml(FileName))

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__=('ListFile','droid')

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

ListFile('標題','/sdcard/qpython')

按“確認”返回:'/sdcard/qpython/xx.py'

總結

以上是生活随笔為你收集整理的python安卓附带文件_Android QPython3 可视化-文件(夹)选择:ListFile.py的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。