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.

fmt key better documentation?

See original GitHub issue

The issue:

I can’t find anything in the documentation on how to format the float output of the OpenWeather widget. I tried searching for fmt everywhere but it’s just ("fmt", "{}", "How to format the text") .

Required:

  • I have searched past issues to see if this bug has already been reported.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
elParaguayocommented, Apr 10, 2022

OK, I’ll explain:

Widgets that display text typically inherit base._TextBox directly, or indirectly.

base_TextBox has a property called formatted_text which takes the text and basically does self.fmt.format(text).

The output of this property is what is displayed in the widget.

So, if you’re using, say, the OpenWeather widget and have it set up to show the temperature, leaving fmt as {} will make no difference to the output. However, if you set fmt to The temperature is: {} your widget will fill the curly brackets with the temperature.

fmt is therefore a way to add additional text, prefixes, markup etc to text based widget. It’s particularly useful on those widgets where you can’t edit the text. Take CurrentScreen for instance. That widget, by default, just shows the number of the screen. If you set fmt to Current screen: {} you now get that additional text in front of the screen number.

This allows you to add extra text to the widget without needing to use a separate TextBox widget to add more text.

2reactions
ervinpopescucommented, Apr 10, 2022

Thanks a lot. I’d appreciate some more documentation on fmt tho 😃

I agree, but what would be a better description for it? Also, adding an example to it would probably make it way clearer.

If I knew what fmt does, I would submit a PR, not write an issue 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Reference — fmt 9.1.0 documentation
Small, safe and fast formatting library.
Read more >
Improve documentation for best practices around ... - GitHub
Hi, I am new to fmt and since my small issue deals with the same section of the documentation, I decided to put...
Read more >
fmt - Go Packages
Package fmt implements formatted I/O with functions analogous to C's printf and scanf. ... A newline with zero or more spaces before it...
Read more >
JSTL fmt Tag message - Oracle Help Center
Maps key to localized message and performs parametric replacement. Tag Information. Tag Class, org.apache.taglibs.standard.tag.rt.fmt.MessageTag.
Read more >
JSTL - Core <fmt:message> Tag - Tutorialspoint
Attribute, Description, Required, Default. key, Message key to retrieve, No, Body. bundle, Resource bundle to use, No, Default bundle.
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