用于jupyter/ipython和ipywidgets的python文件选择器小部件
ipyfilechooser的Python项目详细描述
IPY文件选择器
一个简单的python文件选择器小部件,用于jupyter/ipython和ipywidgets中。所选路径和文件分别通过.selected_path
和.selected_filename
可用,或者通过.selected
作为单个组合文件路径可用。可以使用.reset()
将对话框重置为其默认路径和文件名。
当一个类型化的文件名与当前文件夹中的现有文件条目匹配时,条目将被突出显示。为了强调重写现有文件的风险,如果文件不存在,则选择的文件路径以绿色显示,如果它是橙色的话。
用法
from ipyfilechooser import FileChooser
# Create and display a FileChooser widget
fc = FileChooser('/Users/crahan/FC demo')
display(fc)
# Print the selected path, filename, or both
print(fc.selected_path)
print(fc.selected_filename)
print(fc.selected)
# Change defaults and reset the dialog
fc.default_path = '/Users/crahan/'
fc.default_filename = 'output.txt'
fc.reset()
# Shorthand reset
fc.reset(path='/Users/crahan/', filename='output.txt')
# Change hidden files
fc.show_hidden = True
# Change the title (use '' to hide)
fc.title = '<b>FileChooser title</b>'
函数和变量
fc.reset()
fc.refresh()
fc.show_hidden
fc.rows
fc.title
fc.default
fc.default_path
fc.default_filename
fc.selected
fc.selected_path
fc.selected_filename