-1

When I run my code for sg.Radio I get the following error, please could someone help?

TypeError: init() missing 1 required positional argument: 'group_id'

[sg.Radio('1',key= 'RADIO1', enable_events = True,size=(10,1)),
    sg.Radio('2', key= 'RADIO2',enable_events = True, default=False, size=(10,1)),
    sg.Radio('3', key='RADIO3',enable_events = True, default=False, size=(12,1)),
    sg.Radio('4', key='RADIO4', enable_events = True,default=False, size=(12,1))]]
azro
  • 53,056
  • 7
  • 34
  • 70
  • Note the docs for [`Radio`](https://pysimplegui.readthedocs.io/en/latest/call%20reference/#radio-element). It requires a `group_id` argument, as the error mentions. – Carcigenicate Oct 19 '20 at 17:13
  • The error is pretty explicit, you need to add `group_id` as a parameter when build the objects, what don't you understand ? – azro Oct 19 '20 at 17:14

1 Answers1

2

You need to modify your syntax and give a group_id=<some_name> parameter.

The reason for this is that it is a radio button that allows you to select only one value from a particular group(as opposed to a check box where you can select multiple values).

Shweta
  • 135
  • 7
  • thank you! did not realise this as I am quite new to this –  Oct 19 '20 at 17:27
  • Future tip.....read the error messages. They may look scary or complex. You copied, as the second line of your post, the answer to your problem: TypeError: init() missing 1 required positional argument: 'group_id'. Right? It tells you specifically that you're missing 1 required argument and goes on to tell you which one. The PySimpleGUI documentation is extensive but easy to navigate. Look up the Radio element in the call ref https://pysimplegui.readthedocs.io/en/latest/call%20reference/#radio-element – Mike from PSG Oct 20 '20 at 12:18