Skip to content

Instantly share code, notes, and snippets.

@WillKoehrsen
Created January 27, 2019 14:18
Show Gist options
  • Save WillKoehrsen/62b22c651565d85959523196444cf297 to your computer and use it in GitHub Desktop.
Save WillKoehrsen/62b22c651565d85959523196444cf297 to your computer and use it in GitHub Desktop.
# 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