In a discussion under this answer to Make PySimpleGUI Radio Buttons generate events I expressed that I felt that if some buttons (elements) in a single group of radio buttons generated an event and others in the same cluster didn't, it would be "weird".

I think it's weird to have a group of radio buttons where some generate events and others don't. My only examples before this were the actual buttons on radios from where the term originates, Matplotlib's RadioButton widget, and every UI I've ever used as an end user. So it's de facto weird to me. I'll look at some other examples now to see how common mixed buttons (some generating events, some not) is.

Am I wrong?

A simple way to answer might be to just give one or a few examples where this would be used and a package besides PySimpleGUI provides this.


Here's the simple answer.

import PySimpleGUI as sg

layout = [  [sg.Text('Submit a new bug - How urgent is your problem?')],
            [sg.Radio('Normal', 1, True,  key='-NORMAL-'), sg.Radio('Urgent', 1, key='-URGENT-'), sg.Radio('Emergency', 1,enable_events=True, key='-EMERGENCY-')],
            [sg.Button('Go'), sg.Button('Exit')]  ]

window = sg.Window('Window Title', layout)

while True:             # Event Loop
    event, values = window.read()
    print(event, values)
    if event in (None, 'Exit'):
    if event == '-EMERGENCY-':
        if sg.popup_yes_no('Are you sure you want to submit this as an urgent bug??') != 'Yes':

If it's de dacto weird to you, then you'll find tkinter and Qt de facto weird too as they both work this way. Generation of events is controlled on a per-Widget basis for these 3 packages and others.

| improve this answer | |
  • It's de facto weird to me because I'd not seen it before, thus the question. Now it is somewhat less so. Thanks! – uhoh Mar 26 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.