如何使用python破折号显示多个图像

阿提拉格

我正在执行此操作以显示多个带有破折号的图像,但是它显然不起作用,因为它仅显示一个图像。

for i in images:
    app.layout = html.Div([
        html.Div([
            html.A([
                html.Img(
                    src=app.get_asset_url(i),
                    style={
                        'height' : '40%',
                        'width' : '40%',
                        'float' : 'left',
                        'position' : 'relative',
                        'padding-top' : 0,
                        'padding-right' : 0
                    }
                )
            ], href='https://www.google.com'),
        ])
    ]) 

这样做可能是最简单的方法。考虑到这些是图像而不是情节。

阿提拉格

我设法使它像这样

def generate_thumbnail(image):
    return html.Div([
        html.A([
            html.Img(
                src = app.get_asset_url(i),
                style = {
                    'height': '40%',
                    'width': '40%',
                    'float': 'left',
                    'position': 'relative',
                    'padding-top': 0,
                    'padding-right': 0
                }
            )
        ], href = 'https://www.google.com'),
    ])

images_div = []
for i in images:
    images_div.append(generate_thumbnail(i))
app.layout = html.Div(images_div)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章