Comments (4)
The WrappedText widget can take a height parameter (widget doc)
If you set it to your desired height you should be good to go.
This might throw off the centering of the text, but here's your code with some padding. Note: was using the CG-pixel-3x5-mono font.
def display_error(msg):
return render.Root(
child = render.Row(
children = [
render.Box(
width = 20,
height = 32,
color = "#000",
child = render.Image(
src = ERROR_ICON,
width = 16,
height = 16
)
),
render.Box(
child = render.Padding(
pad = (0,10,0,0),
child = render.WrappedText(
height = 32,
content = msg,
color = "#FFF",
linespacing = 1,
font = "CG-pixel-3x5-mono",
)
),
),
],
),
)
Hope this helps! If it doesn't work plz lmk
from pixlet.
Hi @vlauffer
Thanks for your response. I was aware of the height parameter, and I agree with you that it works with that parameter. And as you suggested, with some padding, one might get also the centering correct.
However, this approach does not solve the bug that produces the erroneus output. While your approach works, it still requires manual fine tuning. I would therefore say, your approach is a workaround until that bug is fixed.
from pixlet.
@LukiLeu just realized you mentioned the height parameter in the very first sentence of the original post (facepalm) my bad. I see what you mean now though. I'm pretty interested in finding out why the text gets cut off without a set height, and why setting height relocates the text to the top instead of center...
I'm very new to Go and Starlark but I'm gonna try to figure out why this happens.
adding these links here incase I lose them:
wrappedtext doc, DrawStringWrapped function, font metrics
from pixlet.
My guess is, that the linespacing is not added to an internal calculated height and only the bare height of the font multiplied with the nunber of lines is used
from pixlet.
Related Issues (20)
- Timezone conversion broken on Windows HOT 1
- Allow variable Root width & height HOT 1
- Add extraParams argument to the OAuth2 schema HOT 1
- pixlet login crashes after authorization HOT 4
- humanize.ftoa(), numbers with 0s before the decimal get truncated when rounding to 0 digits HOT 2
- the hello-world example in the readme/curl-output is missing "render" HOT 1
- bitcoin examples are very dated
- Add a linux/arm release HOT 1
- "encrypt" command will not work with secrets prefixed by "-" character HOT 2
- Way to ignore bad SSL/TLS certificates?
- pixlet login oauth failure
- make fails on MacOS Ventura with file not found HOT 3
- pixlet login redirects to localhost:8085
- [Feature] Support for zip file processing HOT 3
- Feature request: animation duration introspection HOT 3
- Tidbyt is not invalidating cache on device HOT 2
- Multi-select Schema
- UI to visualize/confirm schema before publish HOT 1
- Pass source name into generated schema handler
- Local deploy to tidbyt - does app refresh? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pixlet.