question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

proper way to update widget style (such as font-size) ?

See original GitHub issue

Hello, I’ve noticed that since version 5.0 it is not possible to set style parameters such as ‘font-size’ with the following syntax

from ipywidgets import widgets
w=widgets.Text("example",font_size=75)
display(w)

neither this way:

from ipywidgets import widgets
w=widgets.Text("example")
w.font_size=75
display(w)

What is the proper way? I’ve found anything in the doc 😦

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:23 (11 by maintainers)

github_iconTop GitHub Comments

11reactions
sjdv1982commented, Dec 23, 2017

@meyermj, @patrickhoebeke : I had the same problem. After studying what CSS is and how it works, I managed a hack:

import ipywidgets
w = ipywidgets.Text("test", description="Title")
w.add_class("mytext")
w
%%html
<style>
.mytext > .widget-label {
    font-style: italic;
    color: blue;
    font-size: 30px;
}
.mytext > input[type="text"] {
    font-size: 20px;
    color: red;
}
</style>

Note that %%html is simply a wrapper around IPython.display.display_html. So it would be possible to create some kind of Pythonic (kernel-side) front-end that generates and displays the CSS. At the very least, one could use something less awkward than pure CSS (it appears that there are dialects with improved syntax, like SASS, which are pre-processed/compiled into CSS).

But, in addition, one could inform a smart (kernel-side) front-end about the internal DOM structure of the ipywidget.To my taste, this is a more flexible way to allow styling than the current method of exposing arbitrary attributes to the model-view-comm framework. But I am not really qualified to judge, since I know nothing about (browser-side) front-end development.

10reactions
djleach-belcancommented, Aug 24, 2017

It does not seem possible to modify the font size or color of a Label or Text widget. How should this be accomplished?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to increase the font size of a Text widget? - Tutorialspoint
To configure the text properties of the a widget, we can use the font('font-family font-size font-style) attribute by defining its font-family, ...
Read more >
How to change a widget's font style without knowing the ...
There's a much better way than using .config() to change your application font, especially if your goal is to change the font for...
Read more >
How to Change the Size and Style of Font in WordPress (NO ...
No plugin is needed either! I'll show you how to quickly and easily change the font size and style in your blog posts...
Read more >
How to change Font Style of Text Widget - Flutter Campus
In this example, we are going to show the way to change style of font inside text widget such as font-weight, font size,...
Read more >
How to Change Font Size of Widget Title? - ThemeGrill Docs
From your WordPress Dashboard, go to Appearance -> Customize -> Content -> Widgets · Scroll to Typography. · Change the font size of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found