Ai
4 Star 4 Fork 0

Gitee 极速下载/pysimplegui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/PySimpleGUI/PySimpleGUI
克隆/下载
Demo_Tabs_Simple.py 2.38 KB
一键复制 编辑 原始数据 按行查看 历史
timkay@not.com 提交于 2024-02-12 23:14 +08:00 . First release of PySimpleGUI 5!
#!/usr/bin/env python
"""
Demo - Simple Tabs
How to use the Tab Element and the TabGroup Element
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.
"""
import PySimpleGUI as sg
# Simple example of TabGroup element and the options available to it
sg.theme('Dark Red') # Please always add color to your window
# The tab 1, 2, 3 layouts - what goes inside the tab
tab1_layout = [[sg.Text('Tab 1')],
[sg.Text('Put your layout in here')],
[sg.Text('Input something'), sg.Input(size=(12,1), key='-IN-TAB1-')]]
tab2_layout = [[sg.Text('Tab 2')]]
tab3_layout = [[sg.Text('Tab 3')]]
tab4_layout = [[sg.Text('Tab 3')]]
# The TabgGroup layout - it must contain only Tabs
tab_group_layout = [[sg.Tab('Tab 1', tab1_layout, key='-TAB1-'),
sg.Tab('Tab 2', tab2_layout, visible=False, key='-TAB2-'),
sg.Tab('Tab 3', tab3_layout, key='-TAB3-'),
sg.Tab('Tab 4', tab4_layout, visible=False, key='-TAB4-')]]
# The window layout - defines the entire window
layout = [[sg.TabGroup(tab_group_layout,
enable_events=True,
key='-TABGROUP-')],
[sg.Text('Make tab number'), sg.Input(key='-IN-', size=(3,1)), sg.Button('Invisible'), sg.Button('Visible'), sg.Button('Select'), sg.Button('Disable')]]
window = sg.Window('My window with tabs', layout, no_titlebar=False)
tab_keys = ('-TAB1-','-TAB2-','-TAB3-', '-TAB4-') # map from an input value to a key
while True:
event, values = window.read() # type: str, dict
print(event, values)
if event == sg.WIN_CLOSED:
break
# handle button clicks
if event == 'Invisible':
window[tab_keys[int(values['-IN-'])-1]].update(visible=False)
if event == 'Visible':
window[tab_keys[int(values['-IN-'])-1]].update(visible=True)
if event == 'Select':
window[tab_keys[int(values['-IN-'])-1]].select()
if event == 'Disable':
window[tab_keys[int(values['-IN-']) - 1]].update(disabled=True)
window.close()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mirrors/pysimplegui.git
git@gitee.com:mirrors/pysimplegui.git
mirrors
pysimplegui
pysimplegui
master

搜索帮助