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

feat: categorical slider [WIP] #256

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tlambert03
Copy link
Member

@tlambert03 tlambert03 commented Oct 15, 2024

This adds a new QCategoricalSlider and QLabeledCategoricalSlider, when you want a slider to select from a discrete set of objects (rather than numbers). Similar to a combobox I guess, but easier to change between all the values.

API still needs consideration

from qtpy.QtWidgets import QApplication

from superqt.sliders import QLabeledCategoricalSlider

app = QApplication([])
slider = QLabeledCategoricalSlider(
    categories=["dog", "cat", "elephant", "bird", "fish"]
)
slider.show()
slider.categoryChanged.connect(lambda category: print(category))
app.exec()
Screen.Recording.2024-10-15.at.6.00.36.PM.mov

edit: the label is now a combobox to allow two-way editing

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 69.53642% with 46 lines in your changes missing coverage. Please review.

Project coverage is 85.95%. Comparing base (952ac33) to head (bb2b79d).

Files with missing lines Patch % Lines
src/superqt/sliders/_categorical_slider.py 35.13% 24 Missing ⚠️
src/superqt/sliders/_labeled.py 80.70% 22 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #256      +/-   ##
==========================================
- Coverage   87.09%   85.95%   -1.15%     
==========================================
  Files          46       47       +1     
  Lines        3433     3503      +70     
==========================================
+ Hits         2990     3011      +21     
- Misses        443      492      +49     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Czaki
Copy link
Contributor

Czaki commented Oct 15, 2024

Maybe also add an enum version of it?

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.

2 participants