iSEEu
September 2, 2023, 7:20pm
1
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),
)
)
iSEEu
September 2, 2023, 8:11pm
3
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),
)
)
)
iSEEu
September 2, 2023, 8:30pm
5
Ah, Thank you @angularfoxdev !
1 Like