我在这篇文章中使用了以下方法来隐藏效果很好的 GUI 元素:
import PySimpleGUIQt as sg
layout = [
[sg.Checkbox('Module Selection', default = False, change_submits= True, key = '_checkbox1_', size=(15,1)),
sg.Text('Module(.xlsx)', size = (15,0.5), auto_size_text = True, justification = 'right', key = '_moduletext_')]
]
window = sg.Window('A2L', layout, icon = u"icon\\index.ico", auto_size_buttons = False).Finalize()
window.Element('_moduletext_').Update(visible = False) #makes the element invisible
values_dict={}
while True: # Event Loop
button, values_dict = window.Read()
if values_dict['_checkbox1_']:
window.Element('_moduletext_').Update(visible = True)
这里的问题是,如果我用单选按钮替换复选框,那么相同的代码不会动态隐藏 gui 元素。下面是带有单选按钮的代码:
import PySimpleGUIQt as sg
layout = [
[sg.Radio('Module Selection','RADIO' default = False, enable_events = True, key = '_radio1_', size=(15,1)),
sg.Text('Module(.xlsx)', size = (15,0.5), auto_size_text = True, justification = 'right', key = '_moduletext_')]
]
window = sg.Window('A2L', layout, icon = u"icon\\index.ico", auto_size_buttons = False).Finalize()
window.Element('_moduletext_').Update(visible = False) #makes the element invisible
values_dict={}
while True: # Event Loop
button, values_dict = window.Read()
if values_dict['_radio1_']:
window.Element('_moduletext_').Update(visible = True)
如何在 pysimpleGUIqt 中使用单选按钮隐藏元素?