Text and clocks¶
text¶
Displays a fixed string.
When you'd want this¶
Use it for anything that doesn't change: a title, a room name, a separator character, or a placeholder while you're
laying out a dashboard. If the text needs to come from somewhere, use rest or a
provider widget instead.
Parameters¶
text(optional): The text to display. Defaults to an empty string.text_size(optional): The size of the text in pixels. If you leave it out, the text grows to fit the widget.font_path(optional): The path to a.ttffile to use. If you leave it out, PyGame's default font is used.color(optional): The color of the text, see Colors. Defaults to[255, 255, 255](white).background_color(optional): A color painted behind the text, see Colors. It covers the whole widget, andpaddingonly moves the text inward. If you leave it out, the widget is transparent.corner_radius(optional): The corner radius ofbackground_color, in pixels. Defaults to0.padding(optional): The gap around the text, in pixels. Defaults to0.align(optional): The horizontal alignment:left,center, orright. Defaults toleft.vertical_align(optional): The vertical alignment:top,center, orbottom. Defaults totop.
If you give a text widget its own background_color, you don't need to wrap it in a grid to give it a panel.
Example¶
- widget: text
text: 'Hello Grydgets!'
text_size: 50
font_path: 'OpenSans-Regular.ttf'
color: [0, 255, 0]
background_color: "#2e3440"
corner_radius: 12
align: center
vertical_align: center
dateclock¶
Displays a 24-hour clock, with the current date underneath.
When you'd want this¶
Use it whenever you want the time and date on the dashboard. The time and the date are drawn as separate lines with their own font and color, so you can do cool stuff like use a serif display font for the time and a sans-serif one for the date.
Parameters¶
time_font_path: The path to a.ttffile to use for the time.date_font_path: The path to a.ttffile to use for the date.color(optional): The color of both lines, see Colors. Defaults to[255, 255, 255](white).time_color(optional): The color of the time only. Overridescolorfor the time.date_color(optional): The color of the date only. Overridescolorfor the date.background_color(optional): A color painted behind the clock, see Colors.corner_radius(optional): The corner radius ofbackground_color, in pixels. Defaults to0.
Example¶
- widget: dateclock
time_font_path: 'fonts/Fraunces-700.ttf'
date_font_path: 'fonts/Inter-400.ttf'
time_color: [236, 239, 244]
date_color: [143, 188, 187]
background_color: [0, 0, 0, 160]
corner_radius: 25
rest¶
Makes an HTTP request on a timer and displays the response as text. It can pull a single value out of a JSON response and wrap it in a format string.
When you'd want this¶
Use it to show a single value from an API: a temperature, a stock price, the state of a Home Assistant sensor. If several widgets need values from the same response, set up a provider instead, so the request is only made once.
Parameters¶
url: The URL to request.json_path(optional): A path to the value to show, likeaddress.cityoritems[0].name. See Data extraction.jq_expression(optional): A jq expression that returns the value to show, like.items[] | select(.active). If you also setjson_path, it's applied first.format_string(optional): A Python format string for the final text, with{}standing in for the value. Defaults to{}.method(optional):GETorPOST. Defaults toGET.payload(optional): A JSON body to send with aPOSTrequest.auth(optional): A bearer token or a username and password, see Authentication.update_frequency(optional): How often to make the request, in seconds. Defaults to30.static(optional): Iftrue, the request is only made once at startup. Use this for values that don't change while the dashboard is running. Defaults tofalse.font_path(optional): The path to a.ttffile to use. If you leave it out, PyGame's default font is used.text_size(optional): The size of the text in pixels. If you leave it out, the text grows to fit the widget.color(optional): The color of the text, see Colors. Defaults to[255, 255, 255](white).background_color(optional): A color painted behind the text, see Colors. It covers the whole widget, andpaddingonly moves the text inward. If you leave it out, the widget is transparent.corner_radius(optional): The corner radius ofbackground_color, in pixels. Defaults to0.padding(optional): The gap around the text, in pixels. Defaults to6.align(optional): The horizontal alignment:left,center, orright. Defaults tocenter.vertical_align(optional): The vertical alignment:top,center, orbottom. Defaults tocenter.