在 PySimpleGUI 中按下按钮后,有没有办法在视觉上按住按钮?

Is there a way to visually hold a button after it's been pressed in PySimleGUI?

我想用用户单击选项来替换下拉菜单。

我目前有这个:

我需要这个:

这是我的代码(包含伪代码,因为我也不知道“deselecting”是如何工作的:

import PySimpleGUI as sg

layout = [

    [ sg.Text("Testing") ],
    [sg.Input(key="in")],

    [ sg.Text ("Language?"), sg.Button("German", key="ger"), sg.Button("French", key="fr")],
]
window = sg.Window("This is for testing purposes", layout)

while True:

    event, values = window.read()

    if event == sg.WINDOW_CLOSED:
        break
    
    if event == "ger":
        deselect("fr") if "fr" is selected
        option = "german"
        ...
    
    if event  == "fr":
        deslect("ger") if "ger" is selected
        option = "french"
        ...

简而言之,我想从下拉菜单 selection 切换到向用户显示他们当前 selecting 按钮 X 作为他们的选项的按钮,如果他们 select 另一个按钮(按钮 Y),然后它会取消 select 按钮 X 并显示现在 select 按钮 Y。

现在没有提供选项 indicatoron,但 tkinter 代码将适用于它。

Normally a radiobutton displays its indicator. If you set this option to zero, the indicator disappears, and the entire widget becomes a “push-push” indicatoron button that looks raised when it is cleared and sunken when it is set. You may want to increase the borderwidth value to make it easier to see the state of such a control.

import PySimpleGUI as sg

layout = [
    [sg.Text("Testing") ],
    [sg.Input(key="in")],
    [sg.Text ("Language?"),
     sg.Radio("German", "Language", key="ger"),
     sg.Radio("French", "Language", key="fr")],
]
window = sg.Window("This is for testing purposes", layout, finalize=True)
for key in ("ger", "fr"):
    window[key].widget.configure(indicatoron=False)
while True:
    event, values = window.read()
    if event == sg.WINDOW_CLOSED:
        break
window.close()