scrollbars
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
scrollbars
How do I get scrollbars for text through Python code? I'm using ui.text(). I suspect it's done with styles, somehow, but I don't really know how to implement styles properly.
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: scrollbars
Scrolled text is a bit complicated, requiring a ui.viewport and one or more ui.bars. Generally, you also want a ui.side to lay them out properly.
Your best bet is to start with the example at ui.viewport, and change the ui.image call to ui.text. You may also want to replace the horizontal scrollbar with a call to ui.null(), as text shouldn't overflow the screen.
Your best bet is to start with the example at ui.viewport, and change the ui.image call to ui.text. You may also want to replace the horizontal scrollbar with a call to ui.null(), as text shouldn't overflow the screen.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: scrollbars
Thanks! Haven't tried it out yet, but it looks doable, or like something else can be worked out if it turns to be troublesome.
Re: scrollbars
All right, I've tried it and it works. Now, I have another problem:vlint wrote:Thanks! Haven't tried it out yet, but it looks doable, or like something else can be worked out if it turns to be troublesome.
Is there a way to determine if the scrollbars are needed? If not, is there a way to return an integer of how many lines of text there are in the viewport? Or, is there already a way to make them only show up when needed?
I wouldn't mind them being there all the time so much if there wasn't a slight flash on them every time I put new text in the viewport (i.e. the scrollbars being called again or something, I guess).
If not, I'll have to come up with an algorithm for determining the right amount of text. I've tried this once before trying the scrollbars, for another method of spanning text, but it was pretty wild and I'd rather not go that route if possible.
Actually, a character count of the string at hand might not be so bad for this, but I'd still rather have something more dynamic, as the font won't always be the same.
Re: scrollbars
I found a way to get rid of the flashing thing—I just set the spacing to 0 and now it's fine.vlint wrote:I wouldn't mind them being there all the time so much if there wasn't a slight flash on them every time I put new text in the viewport (i.e. the scrollbars being called again or something, I guess).
Who is online
Users browsing this forum: recreation, Sugar_and_rice, voluorem