[go: up one dir, main page]

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

ENH: Example how to use dynamic properties and stylesheets #1202

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Punzo
Copy link
Contributor
@Punzo Punzo commented May 6, 2024

Bare bones example how to use dynamic properties and stylesheets in CTK to replace dynamic QPalette hard coded colors (colors associated to widget states: normal, warning, disabled, etc.).
This would allow slicer customizations to replace the dynamic widgets state colors by simply defining them in the styleSheet.

hey @sjh26, @lassoan @jcfr @pieper @cpinter I would appreciate a lot if you can provide feedback. Then if you agree on a solution, I can apply the solution to all the CTK classes that uses the QPalette.

@Punzo Punzo marked this pull request as draft May 6, 2024 08:36
@jcfr
Copy link
Member
jcfr commented May 7, 2024

I suggest to review what we documented here: https://github.com/KitwareMedical/SlicerCustomAppUtilities#styling

@Punzo
Copy link
Contributor Author
Punzo commented May 7, 2024

I suggest to review what we documented here: https://github.com/KitwareMedical/SlicerCustomAppUtilities#styling

hei Jc, thanks for sharing the link. I read the repo documentation, but for me it is not clear how it can solve my specific issue. My use case is:

  1. I do a query in the visual dicom browser and if no results are found, a yellow background is currently applied to the filters lineEdit widgets by modifying the QPalette (e.g. https://github.com/commontk/CTK/pull/1202/files#diff-db5337d6b1bcecfa29648a6ea7aebd0d7561a07032e6f56af1031e34c1ba4e16R893-R903)
  2. If I apply a simple static stylesheet to my customSlicer, the linked QPalette code does not work anymore (the stylesheet overwrites everything).
  3. I see that in https://github.com/KitwareMedical/SlicerCustomAppUtilities you are using dynamic properties, but to me it is still not clear how to update the status of the widget in my use case:
    a) in this draft PR for example I set the property here: https://github.com/commontk/CTK/pull/1202/files#diff-db5337d6b1bcecfa29648a6ea7aebd0d7561a07032e6f56af1031e34c1ba4e16R906-R915
    b) in your repo I see these methods to achive that https://github.com/KitwareMedical/SlicerCustomAppUtilities/blob/main/Modules/Scripted/SlicerCustomAppUtilities/SlicerCustomAppUtilities/__init__.py#L16-L42, but you would still need to observe the visual dicom browser widget, something like a signal. e.g., query failed -> signal -> slicerCustomization python module observe the signal and set the dynamic property with your methods. But this still means we would need to add many signals to change dynamically all the CTK widgets that changes colors dynamically with a QPalette (there are many).

Am I missing something?

@lassoan
Copy link
Member
lassoan commented May 8, 2024

@jcfr please suggest changes that would make this code meet the guidelines.

It is not clear for me how they alcan be used here, because we need modifier not just based on theme (light or dark) but also state (normal, warning, disabled, etc.).

The syntax of block/elelement/modifier also seems to be ambiguous, as each component can consists of multiple words, so double-dash or double-underscore should be used to separate them (while in your examples the light and dark modifier was just separated from the element by a single dash).

@Punzo
Copy link
Contributor Author
Punzo commented May 10, 2024

@jcfr do you think we should discuss this in a videocall? thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants