如何在 PySimpleGUI 中创建可滚动的列
How can I create a column that is scrollable in PySimpleGUI
我想创建一个简单的菜单类型的东西,其中我的 window 被分成两半,我希望左侧可以滚动,但右侧是固定的。
我是 PySimpleGUI 的新手,我浏览了文档中的混乱部分,看起来框架可能是一个不错的方法,但我不太确定我将如何获得一个滚动条。当有更多元素可以放入框架时它是自动的,还是我必须有一些启用它的代码?
如果你运行 help(sg.Column)
那么你应该看到
__init__(self, ..., scrollable=False, vertical_scroll_only=False, ....)
编辑:
您在第 Call reference
页的文档中也有它
https://pysimplegui.readthedocs.io/en/latest/call%20reference/#column-element
import PySimpleGUI as sg
help(sg.Column)
column1 = [
[sg.Text(f'Scrollable{i}')] for i in range(10)
]
column2 = [
[sg.Text(f'Static{i}')] for i in range(10)
]
layout = [
[
sg.Column(column1, scrollable=True, vertical_scroll_only=True),
sg.Column(column2)
]
]
window = sg.Window('Scrollable', layout)
event, values = window.read()
window.close()
编辑:
来自@MikefromPSG 评论的非常有趣的信息:
Calling `sg.main_sdk_help()` will also give you a nice bit of help info.
It's the docstrings that I rely on the most (in PyCharm).
In the help window you'll also find a link to the online call reference
that will launch your browser should you want to go that route.
import PySimpleGUI as sg
sg.main_sdk_help()
我想创建一个简单的菜单类型的东西,其中我的 window 被分成两半,我希望左侧可以滚动,但右侧是固定的。
我是 PySimpleGUI 的新手,我浏览了文档中的混乱部分,看起来框架可能是一个不错的方法,但我不太确定我将如何获得一个滚动条。当有更多元素可以放入框架时它是自动的,还是我必须有一些启用它的代码?
如果你运行 help(sg.Column)
那么你应该看到
__init__(self, ..., scrollable=False, vertical_scroll_only=False, ....)
编辑:
您在第 Call reference
https://pysimplegui.readthedocs.io/en/latest/call%20reference/#column-element
import PySimpleGUI as sg
help(sg.Column)
column1 = [
[sg.Text(f'Scrollable{i}')] for i in range(10)
]
column2 = [
[sg.Text(f'Static{i}')] for i in range(10)
]
layout = [
[
sg.Column(column1, scrollable=True, vertical_scroll_only=True),
sg.Column(column2)
]
]
window = sg.Window('Scrollable', layout)
event, values = window.read()
window.close()
编辑:
来自@MikefromPSG 评论的非常有趣的信息:
Calling `sg.main_sdk_help()` will also give you a nice bit of help info.
It's the docstrings that I rely on the most (in PyCharm).
In the help window you'll also find a link to the online call reference
that will launch your browser should you want to go that route.
import PySimpleGUI as sg
sg.main_sdk_help()