hoffstadt / hoffstadt/DearPyGui

Automatic default_value in radiobutton

Open
#1,472 2 comments 0 reactions 1 assignee Claimed by @Pcothren View on GitHub
priority: medium type: bug
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

**The (small) problem**
```
import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport(title="Viewport")

def print_values():
print("radio1: ", dpg.get_value("radio1"))
print("radio2: ", dpg.get_value("radio2"))

with dpg.window(label="Window", tag="window"):
dpg.add_button(label="Print values", callback=print_values)
dpg.add_radio_button(items=['Yes', 'No'], tag="radio1")
dpg.add_radio_button(items=['Yes', 'No'], tag="radio2", default_value='Yes')

dpg.set_primary_window("window", True)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
```

If you run this example and do nothing except for clicking print values. Then you will see that ``dpg.get_value("radio1")`` returns ``None``. It is not a big problem, since you can just specify default_value. But, it can be confusing since the first option is always selected in the GUI even if default_value is not specified.

**Preferred solution**
I think it would make sense in this situation to return the first list item unless default value is specified.
```
content = [1, 2, 3, 4, 5]

dpg.add_radio_button(items=content) # add default_value=content[0] automatically
```

**Other solutions**
Just have nothing selected in the GUI if default_value is unspecified.

**Note**
This is my first feature request. If it has wrong tags or something, please let me know.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.