整理 PySimpleGUI 官方网站
原文google翻译过来的
https://pysimplegui.readthedocs.io/en/latest/
您将找到有关Elements的信息,所有其他类和函数都位于本手册结尾处。它们位于自述文件的大部分中,按字母顺序排列以便于查找。本节对Elements的讨论旨在教您如何工作。另一部分包含详细的呼叫签名和参数定义。
多行元素 Multiline Element
参数说明:
参数类型 | 参数名 | 说明 | ||
---|---|---|---|---|
str | 力量 | str | default_text | 要显示的初始文字 |
bool | 布尔 | bool | enter_submits | 如果为True,则在此元素中按Enter键将返回Window.Read调用 |
bool | 布尔 | bool | 残障人士 | 设置禁用状态 |
bool | 布尔 | bool | 自动滚屏 | 如果为True,则元素的内容将自动滚动,因为将更多数据添加到末尾 |
int | 整型 | int | border_width | 元素周围边框的宽度(以像素为单位) |
Tuple[int, | 元组[int, | Tuple[int, | 尺寸 | int](宽度,高度),宽度=字符宽,高度=行高 |
bool | 布尔 | bool | auto_size_text | 如果为True,则将调整元素大小以匹配文本的长度 |
str | 力量 | str | 背景颜色 | 背景色 |
str | 力量 | str | text_color | 文字颜色 |
bool | 布尔 | bool | chfange_submits | 不使用。仅针对向后兼容列出-使用enable_events代替 |
bool | 布尔 | bool | enable_events | 打开特定于元素的事件。旋转事件在项目更改时发生 |
bool | 布尔 | bool | do_not_clear | 如果为False,则在Window.Read调用返回时将清除该元素 |
Any | 任何 | Any | 键 | 与window.FindElement和返回值一起使用,以唯一标识此元素,以唯一标识此元素 |
bool | 布尔 | bool | 焦点 | 如果True最初的重点将放在此元素上 |
Union[str, Tuple[str, int]] | 联合[str,元组[str,int]] | Union[str, Tuple[str, int]] | 字形 | 指定字体系列,大小等 |
(int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | (int,int)或((int,int),(int,int))或(int,(int,int))或((int,int),int) | (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | 垫 | 元素(左/右,上/下)或((左,右),(上,下))周围的填充量 |
str | 力量 | str | 工具提示 | 鼠标悬停在元素上时显示的文本 |
List[List[Union[List[str],str]]] | List [List [Union [List [str],str]]] | List[List[Union[List[str],str]]] | right_click_menu | 右键单击此元素时显示的菜单项列表的列表。有关详细格式,请参见用户文档。 |
bool | 布尔 | bool | 可见 | 设置元素的可见性状态 |
Any | 任何 | Any | 元数据 | 可以设置为任何内容的用户元数据 |
得到
返回多行元素的当前内容
Get()
参数类型 | 参数名 | 说明 |
---|---|---|
— | 返回 | 多行元素的当前内容(用作多行的输入类型 |
— | return | current contents of the Multiline Element (used as an input type of Multiline |
设定焦点
将当前焦点设置在此元素上
SetFocus(force=False)
参数说明:
参数类型 | 参数名 | 说明 |
---|---|---|
布尔 | 力 | 如果为True,则将调用focus_force;否则,将调用focus_set |
bool | force | if True will call focus_force otherwise calls focus_set |
设定工具提示
由应用程序调用以更改元素的工具提示文本。通常使用Element Object调用,例如:window.Element(‘key’)。SetToolTip(‘New tip’)。
SetTooltip(tooltip_text)
参数说明:
参数类型 | 参数名 | 说明 |
---|---|---|
力量 | tooltip_text | 要在工具提示中显示的文本。 |
str | tooltip_text | the text to show in tooltip. |
更新资料
更改“多行元素”的某些设置。必须致电Window.Read或Window.Finalize事先
Update(value=None,
disabled=None,
append=False,
font=None,
text_color=None,
background_color=None,
text_color_for_value=None,
background_color_for_value=None,
visible=None,
autoscroll=None)
参数说明:
参数类型 | 参数名 | 说明 | ||
---|---|---|---|---|
str | 力量 | str | 值 | 要显示的新文本 |
bool | 布尔 | bool | 残障人士 | 禁用或启用元素的状态 |
bool | 布尔 | bool | 附加 | 如果为True,则将新值添加到当前值的末尾。如果为False,则内容将被替换。 |
Union[str, Tuple[str, int]] | 联合[str,元组[str,int]] | Union[str, Tuple[str, int]] | 字形 | 指定字体系列,大小等 |
str | 力量 | str | text_color | 文字颜色 |
str | 力量 | str | 背景颜色 | 背景色 |
bool | 布尔 | bool | 可见 | 设置元素的可见性状态 |
bool | 布尔 | bool | 自动滚屏 | 如果为True,则将新文本添加到末尾时向下滚动元素的内容 |
捆绑
用于将tkinter事件添加到Element。tkinter特定数据位于Element的成员变量user_bind_event中
bind(bind_string, key_modifier)
扩大
使元素扩展以填充X和Y方向上的可用空间。可以指定哪个或两个方向
expand(expand_x=False,
expand_y=False,
expand_row=True)
得到
返回多行元素的当前内容
get()
参数类型 | 参数名 | 说明 |
---|---|---|
— | 返回 | 多行元素的当前内容(用作多行的输入类型 |
— | return | current contents of the Multiline Element (used as an input type of Multiline |
get_size
返回像素的大小。必须小心,因为某些元素使用字符来指定其大小,但是在调用此get_size方法时将返回像素。
get_size()
参数类型 | 参数名 | 说明 |
---|---|---|
— | 返回 | 元素的宽度和高度 |
— | return | width and height of the element |
hide_row
隐藏元素所在的整行。如果在隐藏元素(包括行容器)时必须删除所有空间,请使用此选项
hide_row()
打印
像Python一样正常打印,除了将输出路由到多行元素,并根据需要添加颜色
print(args=*<1 or N object>,
end=None,
sep=None,
text_color=None,
background_color=None,
autoscroll=True)
参数说明:
参数类型 | 参数名 | 说明 | ||
---|---|---|---|---|
List[Any] | 清单[任何] | List[Any] | args | 要打印的参数 |
str | 力量 | str | 结束 | 与印刷用途一样使用的最终字符 |
str | 力量 | str | 九月 | 像打印一样的分隔字符 |
str | 力量 | str | text_color | 文字颜色 |
str | 力量 | str | 背景颜色 | 线条的背景色 |
set_cursor
设置当前元素的光标。
set_cursor(cursor)
set_focus
将当前焦点设置在此元素上
set_focus(force=False)
参数说明:
参数类型 | 参数名 | 说明 |
---|---|---|
— | 返回 | 当前显示在按钮上的文本 |
布尔 | 力 | 如果为True,则将调用focus_force;否则,将调用focus_set |
bool | force | if True will call focus_force otherwise calls focus_set |
set_size
将元素的大小更改为特定大小。可以为其中一种尺寸指定“无”,以便仅更改元素尺寸之一。
set_size(size=(None, None))
参数说明:
参数类型 | 参数名 | 说明 |
---|---|---|
元组[int,int] | 尺寸 | 字符大小,通常为行。在某些情况下,它们是像素 |
Tuple[int, int] | size | The size in characters, rows typically. In some cases they are pixels |
set_tooltip
由应用程序调用以更改元素的工具提示文本。通常使用Element Object调用,例如:window.Element(‘key’)。SetToolTip(‘New tip’)。
set_tooltip(tooltip_text)
参数说明:
参数类型 | 参数名 | 说明 |
---|---|---|
力量 | tooltip_text | 要在工具提示中显示的文本。 |
str | tooltip_text | the text to show in tooltip. |
解除绑定
从Element中移除先前绑定的tkinter事件。
unbind(bind_string)
unhide_row
取消隐藏(再次显示)Element所在的行容器。请注意,它很可能会重新出现在窗口/容器的底部。
unhide_row()
更新
更改“多行元素”的某些设置。必须致电Window.Read或Window.Finalize事先
update(value=None,
disabled=None,
append=False,
font=None,
text_color=None,
background_color=None,
text_color_for_value=None,
background_color_for_value=None,
visible=None,
autoscroll=None)
参数说明:
参数类型 | 参数名 | 说明 | ||
---|---|---|---|---|
str | 力量 | str | 值 | 要显示的新文本 |
bool | 布尔 | bool | 残障人士 | 禁用或启用元素的状态 |
bool | 布尔 | bool | 附加 | 如果为True,则将新值添加到当前值的末尾。如果为False,则内容将被替换。 |
Union[str, Tuple[str, int]] | 联合[str,元组[str,int]] | Union[str, Tuple[str, int]] | 字形 | 指定字体系列,大小等 |
str | 力量 | str | text_color | 文字颜色 |
str | 力量 | str | 背景颜色 | 背景色 |
bool | 布尔 | bool | 可见 | 设置元素的可见性状态 |
bool | 布尔 | bool | 自动滚屏 | 如果为True,则将新文本添加到末尾时向下滚动元素的内容 |