PySimpleGUI文本框输出,用于选择单选按钮后的信息

问题描述

所以我现在想做的是,如果我单击一个单选按钮,则有关该方法的一些信息应自动显示在GUI中,但我似乎无法正确处理。 我想也许我可以通过使用if语句来完成它,但是什么也没发生。

import PySimpleGUI as sg

# List for Radiobuttons
radio_choices = ["Method 1","Method 2","Method 3","Method 4"]

layout = [[sg.Text("Choose Method")],*[[sg.Radio(text,1),] for text in radio_choices],[sg.Button("Start"),sg.Button("Stop"),sg.Button("Exit")]


          ]

window = sg.Window("Choose Method",layout,size=(350,350))

while True:
    event,values = window.Read()

    
    if event == "Exit" or event == sg.WIN_CLOSED:
        break

    if event == radio_choices[0]:
        sg.Text("Method 1 description")
window.close()

解决方法

尝试一下:

const