You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After creating a radio button with: radio = dpg.add_radio_button(["A", "B", "C"], default_value="B")
How do I get the index of the pressed button? dpg.get_value(radio) returns the selected string, but I'm looking for the index (e.g 0 for 'A').
I can use the following as a work around, but it seems like there should be a better way.
val = dpg.get_value(radio)
items = dpg.get_item_configuration(radio)
idx = items['items'].index(val)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
After creating a radio button with:
radio = dpg.add_radio_button(["A", "B", "C"], default_value="B")
How do I get the index of the pressed button?
dpg.get_value(radio)
returns the selected string, but I'm looking for the index (e.g 0 for 'A').I can use the following as a work around, but it seems like there should be a better way.
Beta Was this translation helpful? Give feedback.
All reactions