Help with centering vertically

I’m trying to vertically center the output of one line of scrolling text but am not sure how to do that. Right now, the text appears on the top line but would rather have if centered. Any ideas?

Here is my code:

load(“render.star”, “render”)
load(“http.star”, “http”)

URL = “http://192.168.XX.XX/apps/api/615/devices/1070?access_token=XXXXXXXXXX

def main():
rep = http.get(URL)
if rep.status_code != 200:
fail(“Request failed with status %d”, rep.status_code)

value = rep.json()["attributes"][0]["currentValue"]
Addr = str(value)
return render.Root(
	render.Marquee(
	width=64,
	child=render.Text(Addr),
	)
)

You can use a Box widget to center a child object. Here’s the docs on that one! Tidbyt | Dev

render.Box(
	child = render.Marquee(
	width=64,
	child=render.Text(Addr),
	)
)

Unfortunately I get the following error when replacing my code with yours:

error loading applet: error running script: expected app implementation to return Root(s) but found: NoneType

My code sample provided would only replace your Marquee code, you still need the render.Root() part. so the entire code would look like:

value = rep.json()["attributes"][0]["currentValue"]
Addr = str(value)
return render.Root(
	render.Box(
	child = render.Marquee(
	width=64,
	child=render.Text(Addr),
	)
)
)

Ah, Thank you @angularfoxdev!

1 Like