在Taipy创建一个用户友好的链接选择器:如何在选择器中显示链接列表

huangapple go评论90阅读模式
英文:

Creating a User-Friendly Link Selector in Taipy: How to Display a List of Links in a Selector

问题

我想创建一个小型的Taipy应用,我可以在其中从选择器、表格或切换按钮中选择图像。

我有一列图像链接,我需要显示它们,以便用户可以选择其中一个选项。是否有一种方法可以使用包含图像链接和文本的列表,并在用户友好的界面(UI)中显示它们?

英文:

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)?

答案1

得分: 2

你可以在Taipy中使用图标进行此操作,如果你愿意的话。示例在文档这里中。然后可以显示一列带有一些文本的图像(图标)。

下面的代码是应用此功能以获取图像链接的一个小示例。请注意,也可以通过提供本地图像的路径来实现。

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()

在Taipy创建一个用户友好的链接选择器:如何在选择器中显示链接列表

英文:

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 = &quot;https://s18670.pcdn.co/wp-content/uploads/GettyImages-1135297525.jpg&quot;
img_2 = &quot;https://3.bp.blogspot.com/_kSiL_6q6sXI/TSjKjZRi_nI/AAAAAAAAAg0/DAWJ7Omn1c8/s640/2011_tropical_rainforest_animals_pictures_jaguar.jpg&quot;
img_3 = &quot;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&quot;


list_img = [(img_1, Icon(img_1, &quot;Image 1&quot;)),
            (img_2, Icon(img_2, &quot;Image 2&quot;)),
            (img_3, Icon(img_3, &quot;Image 3&quot;))]

selected_image = list_img[0]

md = &quot;&quot;&quot;
&lt;|{selected_image}|selector|lov={list_img}|&gt;

&lt;|{selected_image[0]}|image|&gt;
&quot;&quot;&quot;

Gui(md).run()

在Taipy创建一个用户友好的链接选择器:如何在选择器中显示链接列表

huangapple
  • 本文由 发表于 2023年3月3日 18:00:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75625609.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定