代码拉取完成,页面将自动刷新
import PySimpleGUI as sg
"""
Copyright 2023 PySimpleSoft, Inc. and/or its licensors. All rights reserved.
Redistribution, modification, or any other use of PySimpleGUI or any portion thereof is subject to the terms of the PySimpleGUI License Agreement available at https://eula.pysimplegui.com.
You may not redistribute, modify or otherwise use PySimpleGUI or its contents except pursuant to the PySimpleGUI License Agreement.
"""
sg.theme('GreenTan')
col1 = sg.Col([[sg.Text('in pane1', text_color='blue')],
[sg.Text('Pane1')],
[sg.Text('Pane1')],
])
col2 = sg.Col([[sg.Text('in pane2', text_color='red')],
[sg.Text('Pane2')],
[sg.Input('', key='-IN2-')],
[sg.Text('Pane2')],
[sg.Text('Pane2')],
], key='-COL2-', visible=False)
col3 = sg.Col([[sg.Text('in pane 4', text_color='green')],
[sg.Input(key='-IN3-', enable_events=True)],
], key='-COL3-', visible=False)
col4 = sg.Col([[sg.Text('Column 4', text_color='firebrick')],
[sg.Input()],
], key='-COL4-')
col5 = sg.Col([[sg.Frame('Frame', [[sg.Text('Column 5', text_color='purple')],
[sg.Input()],
])]])
layout = [[sg.Text('Click'), sg.Text('', key='-OUTPUT-')],
[sg.Button('Remove'), sg.Button('Add')],
[sg.Pane([col5,
sg.Col([[sg.Pane([col1, col2, col4], handle_size=15,
orientation='v', background_color='red', show_handle=True,
visible=True, key='-PANE-', border_width=0,
relief=sg.RELIEF_GROOVE), ]]), col3],
orientation='h', background_color=None, size=(160, 160),
relief=sg.RELIEF_RAISED, border_width=0)]
]
window = sg.Window('Window Title', layout, border_depth=5,
default_element_size=(15, 1), resizable=True)
while True: # Event Loop
event, values = window.read()
print(event, values)
if event in (sg.WIN_CLOSED, 'Exit'):
break
if event == 'Remove':
window['-COL2-'].update(visible=False)
window['-COL3-'].update(visible=False)
elif event == 'Add':
window['-COL2-'].update(visible=True)
window['-COL3-'].update(visible=True)
window['-IN2-'].update(values['-IN3-'])
window.close()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。