我正在尝试修改 python 2.7 中 jupyter 标签小部件的字体属性(粗细、颜色等)。例如,我尝试了以下操作:
import ipywidgets as widgets
myLabel= widgets.Label(value = 'Some Label',color = '#ff0000') #change font color to red
myLabel
当我运行这段代码时,我没有收到任何错误,但标签颜色仍然是默认的黑色。
最佳答案
我知道有两种方法。
- HTML 小部件
- 用 latex 标记小部件
text = 'Some text'
htmlWidget = widgets.HTML(value = f"<b><font color='red'>{text}</b>")
labelWidget = widgets.Label(value = r'\(\color{red} {' + text + '}\)')
更新:现在使用 Ipyvuetify....
import ipyvuetify as v
text = 'Some text'
v.Html(tag="div", children=[text], style_ = "color: red; font-weight: bold")
关于python - 更改 jupyter notebook 标签小部件中的字体属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38684791/