在jupyter笔记本标签小部件中更改字体属性 [英] changing font attributes in jupyter notebook label widget
本文介绍了在jupyter笔记本标签小部件中更改字体属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在python 2.7中修改jupyter标签小部件的字体属性(粗细,颜色等).例如,我尝试了以下方法:
I am trying to modify the font attributes (weight, color, etc) of a jupyter label widget in python 2.7. As an example, I have tried the following:
import ipywidgets as widgets
myLabel= widgets.Label(value = 'Some Label',color = '#ff0000') #change font color to red
myLabel
运行这段代码时,我没有收到任何错误,但是标签颜色仍然是默认的黑色.
When I run this bit of code, I get no errors, however the label color remains the default black.
推荐答案
我知道2种方法.
- HTML小部件
- 带有乳胶的标签小工具
text = 'Some text'
htmlWidget = widgets.HTML(value = f"<b><font color='red'>{text}</b>")
labelWidget = widgets.Label(value = r'\(\color{red} {' + text + '}\)')
这篇关于在jupyter笔记本标签小部件中更改字体属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文