Last active
March 20, 2019 19:41
-
-
Save jsignell/86f80c916cd22619083395f5ae9c4220 to your computer and use it in GitHub Desktop.
Multipane File Browser implemented in Panel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import panel as pn | |
path = os.getcwd() | |
def get(event): | |
"""When dir selected populate next pane, remove any extra panes""" | |
got = event.new[0] | |
if os.path.isdir(got): | |
items = sorted(os.listdir(got)) | |
options=dict(zip(items, (os.path.join(got, item) for item in items))) | |
next_pane = pn.widgets.MultiSelect(options=options, size=14) | |
next_pane.param.watch(get, 'value') | |
index = row.objects.index(event.obj) | |
if len(row.objects) > (index + 1): | |
row[index + 1] = next_pane | |
else: | |
row.append(next_pane) | |
last_index = index + 1 | |
else: | |
last_index = row.objects.index(event.obj) | |
while len(row) > last_index + 1: | |
row.pop(last_index + 1) | |
items = sorted(os.listdir(path)) | |
options = dict(zip(items, (os.path.join(path, item) for item in items))) | |
select = pn.widgets.MultiSelect(options=options, size=14) | |
select.param.watch(get, 'value') | |
row = pn.Row(select) | |
row.servable() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Each new dir opens in a new pane like: