【发布时间】:2019-07-12 13:26:05
【问题描述】:
我使用this post 的以下方法来隐藏效果很好的 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 中使用单选按钮隐藏元素?
【问题讨论】:
-
单选按钮通常有多个。不确定单个 Radio 的行为。单个复选框很好,但不是单选按钮。
-
我认为您遇到了错误或未实现单选按钮 enable_events。我以为是,但可能不在 Qt 上。我会优先考虑并查看代码。
-
太好了....这些需要在GitHub上问。
-
这个页面确实有你在此处发布并链接的其他帖子的答案。消息似乎没有通过。
标签: python user-interface visible invisible pysimplegui