Member-only story

UX in Jupyter — User input essentials (Part 2)

Zahid Parvez
5 min readJan 14, 2023

--

In Part 2 of the Jupyter user input essentials series, I will go over displaying images, using buttons, and file selector/uploader. If you are just getting started with ipywidgets, check out part one here.

Photo by Kelly Sikkema on Unsplash

Displaying an image

Displaying images or diagrams in notebooks can be a great way to convay information. Typically, you would use other packages such as OpenCV or Matplotlib to display images, but if you didnt want to have dependencies on those packages, the ipywidgets packages allows you to directly display an image from a file:

file = open("original.jpg", "rb")
image = file.read()
widgets.Image(
value=image,
format='jpg',
width=600,
height=100,
)

Button

A button will allow you to run a function when pressed. it's an alternate way of running code instead of just hitting run on Jupyter code boxes, especially if you are trying to run the same code multiple times. the Button’s attributes are similar to that of the toggle button,

  • description = text on the button, default ‘’,
  • button_style = style of the button…

--

--

Zahid Parvez
Zahid Parvez

Written by Zahid Parvez

I am an analyst with a passion for data, software, and integration. In my free time, I also like to dabble in design, photography, and philosophy.

No responses yet