Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Create widgets
directory = widgets.Dropdown(options=['images', 'nature', 'assorted'])
images = widgets.Dropdown(options=os.listdir(directory.value))
# Updates the image options based on directory value
def update_images(*args):
images.options = os.listdir(directory.value)
# Tie the image options to directory value
directory.observe(update_images, 'value')
# Show the images
def show_images(fdir, file):
display(Image(f'{fdir}/{file}'))
_ = interact(show_images, fdir=directory, file=images)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment