Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing font attributes in jupyter notebook label widget

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.

like image 905
MJS Avatar asked Jul 31 '16 14:07

MJS


1 Answers

There are 2 methods that I know of.

  1. HTML widget
  2. Label widget with latex
text = 'Some text'

htmlWidget = widgets.HTML(value = f"<b><font color='red'>{text}</b>")

labelWidget = widgets.Label(value = r'\(\color{red} {' + text  + '}\)')

enter image description here

Update: and now with Ipyvuetify....

import ipyvuetify as v
text = 'Some text'
v.Html(tag="div", children=[text], style_ = "color: red; font-weight: bold")

enter image description here

like image 58
DougR Avatar answered Sep 18 '22 15:09

DougR