在带有链接的输出ipywidget中显示超链接

时间:2020-07-13 11:32:59

标签: python output jupyter display ipywidgets

我想向输出ipywidget添加几个链接

到目前为止,我做到了:

with wd_LINKS_output:
    display('mylinks: ')
    now= datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    display(now)
    display('https://www.google.com/')

我得到:

enter image description here

我想要: a)摆脱'' b)获取一个漂亮的链接

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

除非您为每行创建一个文本小部件,否则您不能摆脱'标记。这就是Python和IPython显示字符串的方式。

要更清晰地显示文本和链接,请使用ipywidgets中的HTML窗口小部件:

import ipywidgets as widgets

text = widgets.HTML('Hyperlink below:')
link = widgets.HTML(
    value="<a href=http://www.google.com target='_blank'>Go to Google</a>",
)

display(text)
display(link)