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.
解决方案
There are 2 methods that I know of.
HTML widget
Label widget with latex
text = 'Some text'
htmlWidget = widgets.HTML(value = f"{text}")
labelWidget = widgets.Label(value = r'\(\color{red} {' + text + '}\)')