scrapbook icon indicating copy to clipboard operation
scrapbook copied to clipboard

Cool project, however, some suggestions for improvements

Open anaderi opened this issue 4 years ago • 2 comments

  1. it is not obvious how to display a saved display (image)...
  2. There is a an unnecessary ambiguity for the word 'display' here. it denotes type of scrap as well as scrap output flag upon saving
  3. as I glue a display, it is always shown twice. plt.ioff() doesn't help.

here is the snippet for displaying image:

def display_image_scrap(nb, key):

    def stringToRGB(base64_string):
        imgdata = base64.b64decode(base64_string)
        image = Image.open(io.BytesIO(imgdata))
        return image
    
    image = stringToRGB(nb.scraps[key].display['data']['image/png'])
    imsize_inches = (np.array(image.size) / 70).astype('int8').tolist()
    
    fig = plt.figure(figsize=imsize_inches)
    ax = fig.add_axes([0, 0, 1, 1])
    ax.imshow(np.array(image), interpolation='antialiased')
    plt.axis('off')

due to (3) I had to disable image scraping for the moment. :(

anaderi avatar Jan 11 '21 20:01 anaderi

  • it is not obvious how to display a saved display (image)...

Yeah I'd like to improve the contract here to make it better but still easy to use. Happy to hear suggestions.

  • There is a an unnecessary ambiguity for the word 'display' here. it denotes type of scrap as well as scrap output flag upon saving

This comes from the encoder having the 'display' name as well as the contents of the scrap having a display attribute since the visual is independent of the data that generated said visual. Maybe 'display-only' encoder would be clearer naming convention?

  • as I glue a display, it is always shown twice. plt.ioff() doesn't help.

That sounds like a bug that needs investigating

MSeal avatar Jan 11 '21 23:01 MSeal