Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Configurable Colors? #71

Open
jhilker98 opened this issue Dec 24, 2020 · 2 comments
Open

User Configurable Colors? #71

jhilker98 opened this issue Dec 24, 2020 · 2 comments
Labels
Question Further information is requested

Comments

@jhilker98
Copy link

Hey there,

I really enjoy using this library to work on some terminal projects.

Would it be possible to have a user set a color for a particular widget with a config file? I haven't had much luck trying to implement a user-configurable color for one of my projects. I am using a yaml config file. Would this be possible to implement?

@jwlodek jwlodek added the Question Further information is requested label Dec 25, 2020
@jwlodek
Copy link
Owner

jwlodek commented Dec 25, 2020

Sure it should be doable - the procedure I'd recommend is this: in your program create a mapping of color strings to py_cui.COLOR combinations, i.e. "blue" would map to py_cui.BLUE_ON_BLACK, assuming you want a black background. Then, load the yaml file, and set the widget color based on that, using widget.set_color(color_map[yaml_value]) right after initialization, where color_map maps the strings in the yaml file to py_cui values, and yaml_value is the assigned color from the yaml file. You would also need some way to know which widget is assigned which color, so you'd need another field in the yaml file that specifies the current widget.

Hope that steers you in the right direction, glad you enjoy the library!

@jhilker98
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants