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 'ComboBox.current_index' attribute #547

Open
p-j-smith opened this issue Mar 21, 2023 · 1 comment
Open

Add 'ComboBox.current_index' attribute #547

p-j-smith opened this issue Mar 21, 2023 · 1 comment

Comments

@p-j-smith
Copy link

Hi, thanks for making magicgui! It's a very cool project and super useful for quickly making widgets / guis.

At the minute, if I would like to get the current index selected in a ComboBox, I either do something like this:

current_name = container.combobox.current_choice
current_index = container.combobox.choices.index(current_name)

or access the QComboBox directly:

container.combobox._widget._qwidget.currentIndex()

Is there a simpler way to do this? Or would it be possible to add a ComboBox.current_index property? I'd be happy to submit a pr if you'd like this added.

Thanks again!

@tlambert03
Copy link
Member

Hi @p-j-smith, sorry for the delay. That would be a great addition thank you. I think it could be added in magicgui/widgets/bases/_categorical_widget.py. Let me know if you run into any issues

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

No branches or pull requests

2 participants