我认为您遇到了一个错误,或者未实现单选按钮enable_events.我以为是,但可能不在Qt上.我将其作为优先事项并查看代码. I think you've hit either a bug or the Radio Buttons enable_events isn't implemented. I thought it was but may not be on Qt. I'll make it a priority and look at the code.这使我认为,当更改单选按钮而不需要单独的按钮时,应该有一种在PySimpleGUI中生成事件的方法,但是我不知道是否有一个.which makes me think there ought to be a way to generate an event in PySimpleGUI when a radio button is changed without need for a separate button, but I can't figure out if there is one. 问题:PySimpleGUI单选按钮是否可以在更改时生成事件?Question: Is there a way for PySimpleGUI Radio Buttons to generate events when changed?推荐答案当enable_events参数指定了某些更改时,将生成事件.记录在这里: https://pysimplegui.readthedocs.io/en/latest/#radio-elementGenerating events when something changes is specified by the enable_events parameter. Documented here :https://pysimplegui.readthedocs.io/en/latest/#radio-element尝试的例子.也适用于PySimpleGUIQt.Example to try. Works for PySimpleGUIQt too.import PySimpleGUI as sglayout = [ [sg.Text('Radio Button Events')], [sg.Radio('1', 1, enable_events=True, key='R1'), sg.Radio('2',1, enable_events=True, key='R2')], [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'): breakwindow.close() 这篇关于使PySimpleGUI单选按钮生成事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-09 02:49