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

[Proposal] QCheckComboBox #89

Open
MosGeo opened this issue May 14, 2022 · 4 comments
Open

[Proposal] QCheckComboBox #89

MosGeo opened this issue May 14, 2022 · 4 comments

Comments

@MosGeo
Copy link
Contributor

MosGeo commented May 14, 2022

I propose the inclusion of a custom widget for check combobox. This is useful in some scenarios (e.g., select multiple samples). If there is interest, I will clean up my current code, add tests and create an initial pull request for it.

I think it deserves a place in superqt as the default combobox:

  • has a relatively awkward (non-pythonic) way of adding checkable item. It needs multiple lines and you cannot use the additem function.
  • Does not change the checked states of the items when clicked
  • Automatically close when you select any item (to change the checked status).
  • Has the last selected item as a title.

The above can be fixed by overriding some of the functions in combobox in qt. A good starting point is https://stackoverflow.com/questions/47575880/qcombobox-set-title-text-regardless-of-items. There is still things to add to it to make it more user friendly (e.g., additem override, signal for item check state change, ...).

Screenshots
The top one is the default combobox. The bottom one is one possible implementation of CheckComboBox.

python3 9_j59ge6Raij

@tlambert03
Copy link
Member

Hi @MosGeo, I think this could be a nice addition.

I think it deserves a place in superqt as the default combobox:

superqt doesn't really have "defaults" per se, it's just a collection of things that libraries can use. It would be fine to add a new widget called QCheckComboBox or CheckableComboBox or something like that... but I probably wouldn't put it forth as the combobox to use.

I have to admit I also find the combo/dropdown UI to be a bit unusual. I think personally I would probably aim for a group of checkboxes (not in a dropdown combobox... though perhaps in a scroll area or your QCollapsible if there are a ton of options). But, as long as this is just a new widget that someone can use if they want to, I wouldn't mind having it in here!

@tlambert03
Copy link
Member

I think it deserves a place in superqt as the default combobox:

ohhh sorry... on rereading now, I realize you were say "because the default combobox ..." 😂 Nevermind my comments about "defaults" ... second paragraph stands though :)

@MosGeo
Copy link
Contributor Author

MosGeo commented May 19, 2022

@tlambert03

  1. I guess "Default" is confusing. Yes, I mean the standard Qt Combobox implementation with checkbox items added inside it instead of qlabel or string. Basically, adding a bunch of standard code and expecting it to work.

  2. The use case for this: If you have a tens of items (e.g., sample 1, sample 2, sample 3) and you want the user to select the ones to run the analysis or something. This means that most of the time, the combobox would be filled dynamically based on the data. For selecting options for algorithms and such, I agree that that a group of checkboxes is the way to go.

I will clean up the code, write tests, and make a draft PR. I just wanted to make sure that it is of interest as every line of code is possible bug waiting to happen in a library, e.g., I see that you fixed quite a few items in QCollapsible :)

@tlambert03
Copy link
Member

I just wanted to make sure that it is of interest as every line of code is possible bug waiting to happen in a library

one nice thing about this library is that the parts aren't terribly interconnected. So adding a new (relatively isolated) widget along with some tests is pretty low risk. If someone finds a bug, it at least means they're interested in the widget, and we can fix it as we go :)

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

No branches or pull requests

2 participants