textual icon indicating copy to clipboard operation
textual copied to clipboard

Add the ability to customise scrollbar bar segments

Open mon opened this issue 1 year ago • 7 comments
trafficstars

Currently, the characters that make up a scrollbar are hardcoded. It would be nice if they could be overridden. Personally, I need to support poor fonts, so need to replace missing glyphs. But it would be neat to use braille characters for a unique style.

Thoughts on making them a classvar, so they can be monkeypatched in for now? I can do that PR if it's an OK change.

mon avatar May 10 '24 01:05 mon

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

github-actions[bot] avatar May 10 '24 01:05 github-actions[bot]

You can patch in a new scrollbar renderable as follow:

from textual.scrollbar import Scrollbar

ScrollBar.renderer = MyScrollbarRenderer

Have a look at how the original is implemented. You can copy that and customize it.

willmcgugan avatar May 10 '24 11:05 willmcgugan

For sure! I was just hoping for an easier way than duplicating the ~72 line render function. Textual is still developing pretty quickly, and I'm wary vendoring too much of its code to fix things.

mon avatar May 10 '24 12:05 mon

@mon For what it's worth, the scrollbar renderer has been in place for well over a year, has been stable as far as I can remember, and is part of the documented API.

davep avatar May 10 '24 13:05 davep

Yeah, that's not going to change. Textual's API is quite stable now.

willmcgugan avatar May 10 '24 13:05 willmcgugan

That's good to know! I guess then - would a PR changing the bar glyphs to be a classvar be rejected? I still do like the idea of a 3-line way to modify the class.

mon avatar May 11 '24 01:05 mon

I think that would be reasonable. Happy to accept a PR.

willmcgugan avatar May 11 '24 11:05 willmcgugan

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

github-actions[bot] avatar Jun 02 '24 17:06 github-actions[bot]