代码拉取完成,页面将自动刷新
import PySimpleGUI as sg
"""
Demo - Changing your window's theme at runtime
* Create your window using a "window create function"
* When your window's theme changes, close the window, call the "window create function"
Copyright 2021-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.
"""
# ------------------- Create the window -------------------
def make_window(theme=None):
if theme:
sg.theme(theme)
# ----- Layout & Window Create -----
layout = [[sg.T('This is your layout')],
[sg.Button('Ok'), sg.Button('Change Theme'), sg.Button('Exit')]]
return sg.Window('Pattern for changing theme', layout)
# ------------------- Main Program and Event Loop -------------------
def main():
window = make_window()
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED or event == 'Exit':
break
if event == 'Change Theme': # Theme button clicked, so get new theme and restart window
event, values = sg.Window('Choose Theme', [[sg.Combo(sg.theme_list(), readonly=True, k='-THEME LIST-'), sg.OK(), sg.Cancel()]]).read(close=True)
print(event, values)
if event == 'OK':
window.close()
window = make_window(values['-THEME LIST-'])
window.close()
if __name__ == '__main__':
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。