python 笔记 PySimpleGUI 图形界面34 - 滑块元素 Slider Element

整理 PySimpleGUI 官方网站
原文google翻译过来的

https://pysimplegui.readthedocs.io/en/latest/
您将找到有关Elements的信息,所有其他类和函数都位于本手册结尾处。它们位于自述文件的大部分中,按字母顺序排列以便于查找。本节对Elements的讨论旨在教您如何工作。另一部分包含详细的呼叫签名和参数定义。

滑块元素 Slider Element

A slider, horizontal or vertical
Slider(range=(None, None),
    default_value=None,
    resolution=None,
    tick_interval=None,
    orientation=None,
    disable_number_display=False,
    border_width=None,
    relief=None,
    change_submits=False,
    enable_events=False,
    disabled=False,
    size=(None, None),
    font=None,
    background_color=None,
    text_color=None,
    key=None,
    pad=None,
    tooltip=None,
    visible=True,
    metadata=None)

参数说明:

参数类型参数名说明
Union[Tuple[int, int], Tuple[float, float]]联合[元组[int,int],元组[float,float]]Union[Tuple[int, int], Tuple[float, float]]范围滑块的范围(最小值,最大值)
Union[int, float]联合[int,float]Union[int, float]默认值滑块的起始值
Union[int, float]联合[int,float]Union[int, float]解析度滑块可移动的最小量
Union[int, float]联合[int,float]Union[int, float]tick_interval滑块旁边应多长时间显示一次可见刻度
str力量str取向“水平”或“垂直”(“ h”或“ v”也适用)
bool布尔booldisable_number_display如果为True,则Slider元素不会显示任何数字
int整型intborder_width元素周围边框的宽度(以像素为单位)
enum枚举enum救济浮雕的风格。RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID
bool布尔boolchange_submits*请勿使用!与enable_events相同
bool布尔boolenable_events如果为True,则移动滑块将生成一个事件
bool布尔bool残障人士设置元素的禁用状态
Tuple[int, int]元组[int,int]Tuple[int, int]尺寸(w =字符宽,h =行高)
Union[str, Tuple[str, int]]联合[str,元组[str,int]]Union[str, Tuple[str, int]]字形指定字体系列,大小等
str力量str背景颜色滑块背景的颜色
str力量strtext_color滑块文本的颜色
any任何any从所有其他元素中唯一标识此元素的值。查找元素或返回值时使用。窗口必须是唯一的
(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工具提示鼠标悬停在元素上时显示的文本
bool布尔bool可见设置元素的可见性状态
Any任何Any元数据可以设置为任何内容的用户元数据

在这里插入图片描述

设定焦点

将当前焦点设置在此元素上

SetFocus(force=False)

参数说明:

参数类型参数名说明
布尔如果为True,则将调用focus_force;否则,将调用focus_set
boolforceif True will call focus_force otherwise calls focus_set

设定工具提示

由应用程序调用以更改元素的工具提示文本。通常使用Element Object调用,例如:window.Element(‘key’)。SetToolTip(‘New tip’)。

SetTooltip(tooltip_text)

参数说明:

参数类型参数名说明
力量tooltip_text要在工具提示中显示的文本。
strtooltip_textthe text to show in tooltip.

更新资料

更改“滑块元素”的某些设置。必须致电Window.Read或Window.Finalize事先

Update(value=None,
    range=(None, None),
    disabled=None,
    visible=None)

参数说明:

参数类型参数名说明
Union[int, float]联合[int,float]Union[int, float]设置当前滑块值
Union[Tuple[int, int], Tuple[float, float]联合[元组[int,int],元组[float,float]Union[Tuple[int, int], Tuple[float, float]范围设置滑块的新范围
bool布尔bool残障人士禁用或启用元素的状态
bool布尔bool可见控制元素的可见性

在这里插入图片描述

捆绑

用于将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_size

返回像素的大小。必须小心,因为某些元素使用字符来指定其大小,但是在调用此get_size方法时将返回像素。

get_size()
参数类型参数名说明
返回元素的宽度和高度
returnwidth and height of the element

hide_row

隐藏元素所在的整行。如果在隐藏元素(包括行容器)时必须删除所有空间,请使用此选项

hide_row()

set_cursor

设置当前元素的光标。

set_cursor(cursor)

set_focus

将当前焦点设置在此元素上

set_focus(force=False)

参数说明:

参数类型参数名说明
返回当前显示在按钮上的文本
布尔如果为True,则将调用focus_force;否则,将调用focus_set
boolforceif True will call focus_force otherwise calls focus_set

set_size

将元素的大小更改为特定大小。可以为其中一种尺寸指定“无”,以便仅更改元素尺寸之一。

set_size(size=(None, None))

参数说明:

参数类型参数名说明
元组[int,int]尺寸字符大小,通常为行。在某些情况下,它们是像素
Tuple[int, int]sizeThe 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要在工具提示中显示的文本。
strtooltip_textthe text to show in tooltip.

解除绑定

从Element中移除先前绑定的tkinter事件。

unbind(bind_string)

unhide_row

取消隐藏(再次显示)Element所在的行容器。请注意,它很可能会重新出现在窗口/容器的底部。

unhide_row()

更新

更改“滑块元素”的某些设置。必须致电Window.Read或Window.Finalize事先

update(value=None,
    range=(None, None),
    disabled=None,
    visible=None)

参数说明:

参数类型参数名说明
Union[int, float]联合[int,float]Union[int, float]设置当前滑块值
Union[Tuple[int, int], Tuple[float, float]联合[元组[int,int],元组[float,float]Union[Tuple[int, int], Tuple[float, float]范围设置滑块的新范围
bool布尔bool残障人士禁用或启用元素的状态
bool布尔bool可见控制元素的可见性

在这里插入图片描述

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值