Replies: 3 comments
-
@zbxiany from ex4nicegui.reactive import rxui
fp = rxui.local_file_picker()
ui.button("open", on_click=fp.open)
ui.run() |
Beta Was this translation helpful? Give feedback.
0 replies
-
这个只是能打开文件夹,那如何显示打开的这个文件夹下所有的文件呢?
|
Beta Was this translation helpful? Give feedback.
0 replies
-
你都有了文件夹路径,使用python中的 pathlib模块即可获得所有的文件路径。所谓的显示,只不过把这些文件路径使用某种组件输出到界面而已。 最简单的就是用label显示,像文件选择组件,只是通过 aggrid 显示。 from nicegui import ui
from ex4nicegui.reactive import rxui
from ex4nicegui import to_ref, effect_refreshable
from pathlib import Path
current_dir = to_ref("")
fp = rxui.local_file_picker(mode="dir")
fp.bind_ref(current_dir)
ui.button("open", on_click=fp.open)
@effect_refreshable
def _():
files = list(Path(current_dir.value).glob("*.*"))
if len(files) <= 0:
ui.label("当前文件夹没有文件")
return
for file in files:
ui.label(str(file.resolve())) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
如题,官网没有这样的例子,拜托
Beta Was this translation helpful? Give feedback.
All reactions