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

Add dynamic_text background colour change #113

Merged
merged 8 commits into from
Jun 13, 2023
Merged

Conversation

fayzull0h
Copy link
Contributor

@fayzull0h fayzull0h commented Jun 4, 2023

Updated dynamic_text.py to have functionality that sets conditions for the data. Based on the conditions, the background colour will change.


This change is Reviewable

Copy link
Member

@BluCodeGH BluCodeGH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple nits and merge conflicts to fix.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @fayzull0h)


sinks/dashboard/items/dynamic_text.py line 19 at r1 (raw file):

        
        self.condition_count = 0
        self.default_color = '#008000'

Default background color should be a light grey like it currently is.


sinks/dashboard/items/dynamic_text.py line 73 at r1 (raw file):

        # If there are conditions, change colour based on them
        #   else, set background to the default color
        if self.condition_count > 0:

You can get rid of this if statement with for/else: https://book.pythontips.com/en/latest/for_-_else.html


sinks/dashboard/items/dynamic_text.py line 78 at r1 (raw file):

                if self.condition_true(condition_reference):
                    background_color = condition_reference.childs[2].value().name()
                    self.setStyleSheet('background: ' + background_color)

Does this interfere with the timeout logic that sets the stylesheet to control the text color? Or will it just go back to the default background color on timeout?

Copy link
Member

@itslinotlie itslinotlie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @fayzull0h)


sinks/dashboard/items/dynamic_text.py line 3 at r1 (raw file):

from pyqtgraph.Qt.QtWidgets import QHBoxLayout, QLabel
from pyqtgraph.Qt.QtCore import QTimer
import pyqtgraph.Qt.QtCore as qtcore

For the sake of consistency, the standard that's been used throughout the repo has been

from pyqtgraph.Qt.QtCore import Qt
...
self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)

@fayzull0h
Copy link
Contributor Author

Does this interfere with the timeout logic that sets the stylesheet to control the text color? Or will it just go back to the default background color on timeout?

I've fixed all the other issues you mentioned. However, I'm not sure what you mean by this one. Could we go over it in more detail on a call or on Slack?

Copy link
Contributor

@KavinSatheeskumar KavinSatheeskumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 5 unresolved discussions (waiting on @BluCodeGH and @fayzull0h)


sinks/dashboard/items/dynamic_text.py line 87 at r2 (raw file):

        comparison = condition.childs[0].value()
        condition_value = condition.childs[1].value()
        data = float(self.widget.text())

If the text is a CAN message or something, this causes a stream of errors.

However, all of these comparisons work on strings, so just don't case to float 👍

The only one that really matters for strings is ==, which works the way it should for strings so I say just not casting is the best solution.

@KavinSatheeskumar KavinSatheeskumar merged commit 0c3fbde into wdr Jun 13, 2023
@KavinSatheeskumar KavinSatheeskumar deleted the add-param-dynamic branch September 2, 2023 02:09
Darth-Raazi added a commit that referenced this pull request Oct 20, 2023
* proof of concept works

* Misc WDR fixes

* dynamic text dash item, fix errors and dynamic sizing

* More fixes

* Limit title length

* Found better alternative than QTimer

now we listen to all can messages (acts as our interrupt function) and then check if the specified peiod has changed, in which case, send the can message.

* Update DAQ config

* Live fixes

* Add printing to replay log

* Fix parsley performance

* Remove CAN message table

* Clean up wdr nitpicks

* Clean up parsley source

* Fix unit tests, autopep8

* Add duplicate item button, optional filter on dynamic text and sorted item keys (#111)

* Update RLCS source

* RLCS source improvements

* Update parsley for live telemetry

* Update requirements.txt to fix imageitem

* Let RLCS control valves

* Add better dashboard error and reset handling

* Autocomplete dashitems

* add general board table item

* wip: use QItemDelegate to add dropdown instead

* improve copy pasting and add deleting to general boards widget

* finish new dropdown implementation and add save/restore support

* improve finding list of paths

* make table rows draggable

* rename general boards to table view

* prevent cell deletion when none is selected

* add store/restore header for table view and ctrl-x for cut

* add support for binary telemetry message

* wip: switch to new binary encoding for telemetry

* support for new binary encoding

* Add dynamic_text background colour change (#113)

* dynamic_text: Added button param to make new params

* dynamic_text: Add conditions to change background color

* dynamic_text: Made requested changes

* dynamic_text: Removed float casting to allow CAN messages

* dynamic_text: Casting condition param to str for comparison

* correct typo

* Format

---------

Co-authored-by: Kavin Satheeskumar <[email protected]>
Co-authored-by: Kavin <[email protected]>

* add support for binary telemetry message

* wip: switch to new binary encoding for telemetry

* support for new binary encoding

* fix some bugs

* Add the ability to select which parsley instance you want to send to

* omnibus to gpsd converter

* Revert "Add the ability to select which parsley instance you want to send to"

This reverts commit 923bcb4.

* Drive changes

Fixes a few bugs, light mode, adds parsley selection

* Fix parsley

* change parsely names to telemetry/none-telemetry; add keep alive bytes for telemetry

* increase table widget margin

* remove commented code project-wide (#117)

* Fix exception caused by empty series

* Fixed plot scaling issue (#119)

Fixed plot scaling issue, removed broken tests and downgraded parsley.

* Added and fixed clear button (#121)

Added a dashboard 'Clear' button

* Deal with 1920x1080 screen resolution on Wayland (#143)

* Another Wayland fix (for dynamic text) (#144)

* Deal with 1920x1080 screen resolution on Wayland

* Fix dynamic text for Wayland

* Removed flakey replay_log unit test

* Ran format.sh to enforce autopep

---------

Co-authored-by: Michael Li <[email protected]>
Co-authored-by: DAQ Computer <[email protected]>
Co-authored-by: Michael <[email protected]>
Co-authored-by: Kavin Satheeskumar <[email protected]>
Co-authored-by: Robert Cai <[email protected]>
Co-authored-by: Rio Liu <[email protected]>
Co-authored-by: Rio <[email protected]>
Co-authored-by: Fayzulloh Ergashev <[email protected]>
Co-authored-by: Kavin <[email protected]>
Co-authored-by: Anthony Chen <[email protected]>
Co-authored-by: MaisimZaman <[email protected]>
Co-authored-by: Ozayr Raazi <[email protected]>
Darth-Raazi added a commit that referenced this pull request Oct 24, 2023
* Rewrote launcher to support macOS

* Fixed KeyError

* Added prompt menu and new profiles

* Terminate all processes when any of them exits

* Added stderr printing

* Updated stdout and stderr printing, changed how programs are terminated

* Added signal for Windows

* Potential fix for signal on Windows

* I hate Windows

* proof of concept works

* Misc WDR fixes

* dynamic text dash item, fix errors and dynamic sizing

* More fixes

* Limit title length

* Found better alternative than QTimer

now we listen to all can messages (acts as our interrupt function) and then check if the specified peiod has changed, in which case, send the can message.

* Update DAQ config

* Live fixes

* Add printing to replay log

* Fix parsley performance

* Remove CAN message table

* Clean up wdr nitpicks

* Clean up parsley source

* Fix unit tests, autopep8

* Add duplicate item button, optional filter on dynamic text and sorted item keys (#111)

* Update RLCS source

* RLCS source improvements

* Update parsley for live telemetry

* Update requirements.txt to fix imageitem

* Let RLCS control valves

* Add better dashboard error and reset handling

* Autocomplete dashitems

* add general board table item

* wip: use QItemDelegate to add dropdown instead

* improve copy pasting and add deleting to general boards widget

* finish new dropdown implementation and add save/restore support

* improve finding list of paths

* make table rows draggable

* rename general boards to table view

* prevent cell deletion when none is selected

* add store/restore header for table view and ctrl-x for cut

* add support for binary telemetry message

* wip: switch to new binary encoding for telemetry

* support for new binary encoding

* Add dynamic_text background colour change (#113)

* dynamic_text: Added button param to make new params

* dynamic_text: Add conditions to change background color

* dynamic_text: Made requested changes

* dynamic_text: Removed float casting to allow CAN messages

* dynamic_text: Casting condition param to str for comparison

* correct typo

* Format

---------

Co-authored-by: Kavin Satheeskumar <[email protected]>
Co-authored-by: Kavin <[email protected]>

* add support for binary telemetry message

* wip: switch to new binary encoding for telemetry

* support for new binary encoding

* fix some bugs

* Add the ability to select which parsley instance you want to send to

* omnibus to gpsd converter

* Revert "Add the ability to select which parsley instance you want to send to"

This reverts commit 923bcb4.

* Drive changes

Fixes a few bugs, light mode, adds parsley selection

* Fix parsley

* change parsely names to telemetry/none-telemetry; add keep alive bytes for telemetry

* increase table widget margin

* remove commented code project-wide (#117)

* Fix exception caused by empty series

* Fixed plot scaling issue (#119)

Fixed plot scaling issue, removed broken tests and downgraded parsley.

* Added and fixed clear button (#121)

Added a dashboard 'Clear' button

* Rewrote launcher to support macOS

* Fixed KeyError

* Added prompt menu and new profiles

* Terminate all processes when any of them exits

* Added stderr printing

* Updated stdout and stderr printing, changed how programs are terminated

* Added signal for Windows

* Potential fix for signal on Windows

* I hate Windows

* Rewrote launcher to dynamically get all sources and sinks

* Added comment

* Deal with 1920x1080 screen resolution on Wayland (#143)

* Another Wayland fix (for dynamic text) (#144)

* Deal with 1920x1080 screen resolution on Wayland

* Fix dynamic text for Wayland

* Added finally section to ensure all spawned process are killed no matter how the program exits

* Removed flakey replay_log unit test

* Ran format.sh to enforce autopep

* Python executable and signal changes for Windows

---------

Co-authored-by: Michael Li <[email protected]>
Co-authored-by: BluCodeGH <[email protected]>
Co-authored-by: DAQ Computer <[email protected]>
Co-authored-by: Michael <[email protected]>
Co-authored-by: Kavin Satheeskumar <[email protected]>
Co-authored-by: Robert Cai <[email protected]>
Co-authored-by: Rio Liu <[email protected]>
Co-authored-by: Rio <[email protected]>
Co-authored-by: Fayzulloh Ergashev <[email protected]>
Co-authored-by: Kavin <[email protected]>
Co-authored-by: Anthony Chen <[email protected]>
Co-authored-by: MaisimZaman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants