Reputation: 55
I am creating a button in Jupyter Notebook using ipywidgets with the following code:
from IPython.display import Javascript, display
from ipywidgets import widgets
from ipywidgets import Layout,interact, interactive, fixed, interact_manual, IntSlider, HBox, Label
def run_all(ev):
display(Javascript('IPython.notebook.execute_cell_range(IPython.notebook.get_selected_index()+1, IPython.notebook.get_selected_index()+2)'))
button = widgets.Button(description="This is a blue colored earth",layout=Layout(width='70%', height='40px'),
style=dict(text_color='#FFFFFF'))
button.style.button_color = '#ff9838'
button.on_click(run_all)
display(button)
Now this is generating the following output:
Now I want to bold certain part of the text in the button.. Let's say "blue colored earth" Can you please help me with it?
Upvotes: 0
Views: 1271
Reputation: 9790
From here:
It looks like it will be possible to use HTML tags in the description when version 8 is out.
Because the description accepts unicode, for now the workaround is to use a site like this Unicode Text Converter to get the bold version of the text and then replace the corresponding part of description with that bold version.
Applying to version extracted from your code with blue colored earth
in bold:
import ipywidgets as widgets
from ipywidgets import Layout
button = widgets.Button(description="This is a 𝗯𝗹𝘂𝗲 𝗰𝗼𝗹𝗼𝗿𝗲𝗱 𝗲𝗮𝗿𝘁𝗵",layout=Layout(width='70%', height='40px'),
style=dict(text_color='#FFFFFF'))
button
Upvotes: 1