3

I want to create a little Taipy application where I would be able to choose an image from a selector, table, or toggle.

I have a list of image links that I need to display where users can choose one of the options. Is there a way to use a list with image links and texts and display it in a user-friendly interface (UI)?

Areth
  • 185
  • 5

1 Answers1

3

You can use Icon in Taipy for this use if you like. An example is in the doc here. It is then possible to display a list of images (Icon) with some text.

The code below is a little example of applying this for image links. Note that it can also work by providing the path to a local image.

from taipy.gui import Gui, Icon

img_1 = "https://s18670.pcdn.co/wp-content/uploads/GettyImages-1135297525.jpg"
img_2 = "https://3.bp.blogspot.com/_kSiL_6q6sXI/TSjKjZRi_nI/AAAAAAAAAg0/DAWJ7Omn1c8/s640/2011_tropical_rainforest_animals_pictures_jaguar.jpg"
img_3 = "https://3.bp.blogspot.com/-qYR8Mv0vdjA/UBAAwoaggQI/AAAAAAAAANs/p6bddoHCVI0/s1600/Ocean-life-wallpapers-marine-life-on-the-seabed-like-fish-plants-animals-hd-wallpaper-02.jpg"


list_img = [(img_1, Icon(img_1, "Image 1")),
            (img_2, Icon(img_2, "Image 2")),
            (img_3, Icon(img_3, "Image 3"))]

selected_image = list_img[0]

md = """
<|{selected_image}|selector|lov={list_img}|>

<|{selected_image[0]}|image|>
"""

Gui(md).run()

Results of code

Florian Jacta
  • 1,143
  • 1
  • 2
  • 5