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

[not-a-bug][help-wanted] How to change border colors of selected buttons #173

Open
strawberry-code opened this issue Feb 1, 2022 · 1 comment
Labels
Bug Something isn't working

Comments

@strawberry-code
Copy link

I am trying to change the color of the borders of the button which the cursor is pointing on.

I am trying by this without success:

def render(self):
      for key in self.master.get_widgets().keys():
          if self.master.get_widgets()[key].is_selected():
              self.master.get_widgets()[key].set_color(py_cui.RED_ON_BLACK)
          else:
              self.master.get_widgets()[key].set_color(py_cui.CYAN_ON_BLACK)

I kindly ask for little help here. What's wrong? If it is possibile to achieve it...

In the picture below I would the button "Show Yes No Popup" be colored in RED_ON_BLACK.

Schermata 2022-02-01 alle 19 22 12

@strawberry-code strawberry-code added the Bug Something isn't working label Feb 1, 2022
@strawberry-code strawberry-code changed the title [not-a-bug][help-requried] How to change border colors of selected buttons [not-a-bug][help-needed] How to change border colors of selected buttons Feb 1, 2022
@strawberry-code strawberry-code changed the title [not-a-bug][help-needed] How to change border colors of selected buttons [not-a-bug][help-wanted] How to change border colors of selected buttons Feb 1, 2022
@jwlodek
Copy link
Owner

jwlodek commented Feb 1, 2022

How are you calling the above function? By default, py_cui interfaces will only re-draw when an action is performed (key press, mouse press). If you want that function to be run periodically, you can use the set_on_draw_update_func() to run the render function on every draw call, and then unlock periodic re-draw of the screen with set_refresh_timeout(). Note that the function set with set_on_draw_update_func() is fired at the start of the draw loop, before the new widget is considered selected.

It may be worthwhile to allow for setting a function to fire per draw call both at the start and end - that would simplify this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants