magicgui icon indicating copy to clipboard operation
magicgui copied to clipboard

Add 'ComboBox.current_index' attribute

Open p-j-smith opened this issue 2 years ago • 1 comments

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!

p-j-smith avatar Mar 21 '23 15:03 p-j-smith

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

tlambert03 avatar Apr 10 '23 14:04 tlambert03