Ai
4 Star 4 Fork 0

Gitee 极速下载/pysimplegui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/PySimpleGUI/PySimpleGUI
克隆/下载
Demo_Design_Pattern_Save_Theme.py 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
timkay@not.com 提交于 2024-02-12 23:14 +08:00 . First release of PySimpleGUI 5!
import PySimpleGUI as sg
"""
Demo - Basic window design pattern
* Creates window in a separate function for easy "restart"
* Saves theme as a user variable
* Puts main code into a main function so that multiprocessing works if you later convert to use
Copyright 2020-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():
# Set theme based on previously saved
sg.theme(sg.user_settings_get_entry('theme', None))
# ----- Layout & Window Create -----
layout = [[sg.T('This is your layout')],
[sg.OK(), sg.Button('Theme', key='-THEME-'), sg.Button('Exit')]]
return sg.Window('Pattern for theme saving', 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 == '-THEME-': # Theme button clicked, so get new theme and restart window
ev, vals = sg.Window('Choose Theme', [[sg.Combo(sg.theme_list(), k='-THEME LIST-'), sg.OK(), sg.Cancel()]]).read(close=True)
if ev == 'OK':
window.close()
sg.user_settings_set_entry('theme', vals['-THEME LIST-'])
window = make_window()
window.close()
if __name__ == '__main__':
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mirrors/pysimplegui.git
git@gitee.com:mirrors/pysimplegui.git
mirrors
pysimplegui
pysimplegui
master

搜索帮助