-
Notifications
You must be signed in to change notification settings - Fork 0
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
Change button colors on arm and disarm #99
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works great in simulation 🎉
But... I don't like how it only applies to the Arm
widget. The Arm
widget uses two ButtonIndicator
s for its buttons, which inherit from our custom IndicatorMixin
widget class. IndicatorMixin
is also inherited by CircleIndicator
, which made pretty green/red circles for statuses like flooding & Pi connection.
CircleIndicator
used broken code that switched between stylesheets that are defined in surface/gui/gui/styles
(the .qss
files). I kinda like your solution (defining the stylesheets in code and switching between them just by setting the stylesheet) better, but I want your solution to work for everything that inherits from IndicatorMixin
. Can you update this to work from IndicatorMixin
?
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
||
# Removes any state | ||
_NO_STATE = '' | ||
def set_initial_stylesheet(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write docstrings for all the methods here
Use the VSCode autodocstring extension with the numpy
preset
src/surface/gui/gui/widgets/arm.py
Outdated
@@ -14,7 +14,7 @@ class Arm(QWidget): | |||
DISARM_REQUEST = CommandBool.Request(value=False) | |||
BUTTON_WIDTH = 120 | |||
BUTTON_HEIGHT = 60 | |||
BUTTON_STYLESHEET = 'QPushButton { font-size: 20px; }' | |||
BUTTON_STYLESHEET = 'QPushButton { font-size: 20px;}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BUTTON_STYLESHEET = 'QPushButton { font-size: 20px;}' | |
BUTTON_STYLESHEET = 'QPushButton { font-size: 20px; }' |
# Removes any state | ||
_NO_STATE = '' | ||
def set_initial_stylesheet(self) -> None: | ||
self._ORIGINAL_STYLESHEET = self.styleSheet() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SCREAMING_SNAKE is for constants, make this self._original_stylesheet
if self.current_state == WidgetState.ON: | ||
return self._ON_STYLESHEET | ||
if self.current_state == WidgetState.OFF: | ||
return self._OFF_STYLESHEET | ||
if self.current_state == WidgetState.INACTIVE: | ||
return self._INACTIVE_STYLESHEET | ||
return '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store _ON_STYLESHEET
etc. in a dictionary of WidgetState
s -> stylesheets
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
def set_inactive(self) -> None: | ||
self.setProperty(IndicatorMixin._PROPERTY_NAME, IndicatorMixin._INACTIVE) | ||
self._update_style() | ||
class WidgetState(Enum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use IntEnum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
Pull Request
What type of PR is this? (check all applicable)
Description
Change the colors of the arm and disarm buttons depending on whether the robot is armed or disarmed
Related Tickets & Documents