Python 3.x 如何从多个widget ipywidgets获取观察到的值
我正在尝试使用ipywidgets中的交互式小部件创建自己的交互式路径选择器,应该有三个选择框,第二个观察第一个选择框中的值,第三个观察前两个选择框中的值,这就是我的问题,我不知道如何添加第三个小部件 这是我的功能代码:Python 3.x 如何从多个widget ipywidgets获取观察到的值,python-3.x,jupyter-notebook,jupyter,interactive,ipywidgets,Python 3.x,Jupyter Notebook,Jupyter,Interactive,Ipywidgets,我正在尝试使用ipywidgets中的交互式小部件创建自己的交互式路径选择器,应该有三个选择框,第二个观察第一个选择框中的值,第三个观察前两个选择框中的值,这就是我的问题,我不知道如何添加第三个小部件 这是我的功能代码: import os import getpass import glob import ipywidgets as widgets from ipywidgets import VBox, HBox, Label, interactive, Box def return_pa
import os
import getpass
import glob
import ipywidgets as widgets
from ipywidgets import VBox, HBox, Label, interactive, Box
def return_paths(raw_path):
"""Create a list of folders in a given path
skipping those with begin with '.' and are empty
"""
paths = [folder for folder in os.listdir(raw_path)
if os.path.isdir(os.path.join(raw_path, folder)) and not folder.startswith('.')
and len(os.listdir(os.path.join(raw_path, folder))) != 0
]
paths.sort()
return paths
def get_select2(*args):
options = return_paths(os.path.join(raw_path, select_1.value))
select_2.options = options
def process(Feature,ID):
print(Feature,ID)
def run():
w = interactive(process, Feature=select_1, ID=select_2)
display(HBox([Label('Select the folder you want process:'), w.children[0], w.children[1]]))
display(w.children[2])
user = getpass.getuser()
raw_path = f'/home/{user}/downloads/0_raw/'
raw_folders = []
select_1 = widgets.Select(
options=return_paths(raw_path),
)
select_2 = widgets.Select()
select_3 = widgets.Select()
select_1.observe(get_select2)
run()
在这一刻,我正在处理两个选定的框,如何添加第三个框?有什么想法吗 我从学术角度理解您为什么要这样做:)但是如果您想要一个简单的小部件文件浏览器,我认为已经存在了:我从学术角度理解您为什么要这样做:)但是如果您想要一个简单的小部件文件浏览器,我认为已经存在了: