图形用户界面小部件#
- class arcade.gui.Rect(x: float, y: float, width: float, height: float)[源代码]#
基类:
NamedTuple
表示用于图形用户界面模块的矩形。直方图是幂等的。
左下角用作固定点(x,y)
- 🧙 repr(self)#
返回格式良好的表示字符串
- bottom#
- center#
- center_x#
- center_y#
- left#
- position#
左下角坐标
- right#
- size#
- top#
- class arcade.gui.UIDummy(*, x=0, y=0, width=100, height=100, size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
-
用于测试的纯色小工具&示例
不应将其细分为用于现实世界的子类。
单击后,它将执行以下操作:
输出其 rect 属性添加到控制台
将其颜色更改为随机的完全不透明颜色
- 参数:
x -- 左下角的X坐标
y -- 左下角的Y坐标
color -- 小工具的填充颜色
width -- 微件的宽度
height -- 小工具的高度
size_hint -- 浮点数元组(0.0-1.0),应请求多少父级空间
size_hint_min -- 以像素为单位的最小宽度和高度
size_hint_max -- 以像素为单位的最大宽度和高度
style -- 未使用
- on_click(event: UIOnClickEvent)[源代码]#
- class arcade.gui.UIInteractiveWidget(*, x: float = 0, y: float = 0, width: float, height: float, size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
基类:
UIWidget
使用鼠标交互(悬停、按下、单击)的小部件的基类
- 参数:
x -- 左下角的X坐标
y -- 左下角的Y坐标
width -- 微件的宽度
height -- 小工具的高度
size_hint -- 浮点数元组(0.0-1.0),应请求多少父级空间
size_hint_min -- 以像素为单位的最小宽度和高度
size_hint_max -- 以像素为单位的最大宽度和高度:参数x:微件的中心x
style -- 未使用
- on_click(event: UIOnClickEvent)[源代码]#
- disabled#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- hovered#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- pressed#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- class arcade.gui.UILayout(*, x: float = 0, y: float = 0, width: float = 100, height: float = 100, children: Iterable[UIWidget] = (), size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
基类:
UIWidget
小部件的基类,用于定位自己或其子部件。
- 参数:
- do_layout()[源代码]#
在渲染之前由UIManager触发,
UILayout
S应该把自己和/或孩子放在哪里。之后将在儿童身上触发DO布局。使用
UIWidget.trigger_render()
为了在下一帧之前触发渲染,如果此小部件的位置或大小发生更改,则会自动执行此操作。
- class arcade.gui.UISpace(*, x=0, y=0, width=100, height=100, color=(0, 0, 0, 0), size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
基类:
UIWidget
预留空间的小工具,也可以有背景色。
- 参数:
x -- 左下角的X坐标
y -- 左下角的Y坐标
width -- 微件的宽度
height -- 小工具的高度
color -- 小工具区域的颜色
size_hint -- 浮点数元组(0.0-1.0),应请求多少父级空间
size_hint_min -- 以像素为单位的最小宽度和高度
size_hint_max -- 以像素为单位的最大宽度和高度
style -- 未使用
- color#
- class arcade.gui.UISpriteWidget(*, x=0, y=0, width=100, height=100, sprite: Sprite | None = None, size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
基类:
UIWidget
使用控制显示内容的精灵创建一个UI元素。
- 参数:
x -- 左下角的X坐标
y -- 左下角的Y坐标
width -- 微件的宽度
height -- 小工具的高度
sprite -- 要嵌入到图形用户界面中的Sprite
size_hint -- 浮点数元组(0.0-1.0),应请求多少父级空间
size_hint_min -- 以像素为单位的最小宽度和高度
size_hint_max -- 以像素为单位的最大宽度和高度
style -- 未使用
- class arcade.gui.UIWidget(*, x: float = 0, y: float = 0, width: float = 100, height: float = 100, children: Iterable[UIWidget] = (), size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
基类:
EventDispatcher
,ABC
这个
UIWidget
类是创建小部件所需的基类。我们还有一些您应该知道的默认值和行为:
- 参数:
x -- 左下角的X坐标
y -- 左下角的Y坐标
width -- 微件的宽度
height -- 小工具的高度
size_hint -- 浮点数元组(0.0-1.0),应请求多少父级空间
size_hint_min -- 以像素为单位的最小宽度和高度
size_hint_max -- 以像素为单位的最大宽度和高度
style -- 未使用
- add(child: W, **kwargs) W [源代码]#
向此添加小部件
UIWidget
作为一个孩子。添加的小部件将接收UI事件并呈现。默认情况下,最新添加的小部件将首先接收UI事件,并在其他小部件上呈现。
- 参数:
child -- 要添加的小部件
index -- 添加微件的位置,没有优先级最高的微件
- 返回:
给定的孩子
- do_render(surface: Surface)[源代码]#
呈现小部件的图形表示,使用
UIWidget.prepare_render()
将绘图区域限制为相对于0,0的小部件RECT和DRAIL。
- prepare_render(surface)[源代码]#
用于渲染的辅助对象,绘图区域将调整到自己的位置和大小。绘制调用必须相对于0,0。这也将防止在小部件区域之外的任何透支
- 参数:
surface -- 用于渲染的曲面
- trigger_render()[源代码]#
这将在渲染下一帧之前延迟渲染,以便
UIWidget.do_render()
不会多次调用。
- with_background(*, color: None | Color = Ellipsis, texture: None | Texture | NinePatchTexture = Ellipsis) UIWidget [源代码]#
设置小工具背景。
颜色或纹理可以用作背景,如果给定了纹理,则可以添加起点和终点以使用该纹理作为背景。
- 参数:
color -- 用作背景的颜色
texture -- 用作背景的纹理或九彩纹理
- 返回:
自性
- with_padding(*, top: int | None = None, right: int | None = None, bottom: int | None = None, left: int | None = None, all: int | None = None) UIWidget [源代码]#
如果设置,则将填充更改为给定值。返回本身:返回:自我
- bottom#
- center#
- center_x#
- center_y#
- children#
- content_height#
- content_rect#
- content_size#
- content_width#
- height#
- left#
- padding#
- position#
返回左下角坐标
- rect: Rect#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- right#
- size#
- size_hint: Tuple[float, float] | None#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- size_hint_max: Tuple[float, float] | None#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- size_hint_min: Tuple[float, float] | None#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- top#
- visible: bool#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- width#
- x#
- y#
- class arcade.gui.UIImage(*, texture: Texture | NinePatchTexture, **kwargs)[源代码]#
基类:
UIWidget
显示纹理的UIWidget。
- texture: Texture | NinePatchTexture#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- class arcade.gui.UIDropdown(*, x: float = 0, y: float = 0, width: float = 100, height: float = 100, default: str | None = None, options: List[str | None] | None = None, style=None, **kwargs)[源代码]#
基类:
UILayout
下拉式布局。单击时,将显示所提供的选项列表。
在单击选项时触发事件,该事件可由
dropdown = Dropdown() @dropdown.event() def on_change(event: UIOnChangeEvent): print(event.old_value, event.new_value)
- 参数:
x -- 左下角的X坐标
y -- 左下角的Y坐标
width -- 每个选项的宽度。
height -- 每个选项的高度。
default -- 显示的默认值。
options -- 单击布局时显示的选项。
style -- 用于设置下拉列表的样式。
- on_change(event: UIOnChangeEvent)[源代码]#
由用户实施,当当前选定的值更改为不同选项时触发。
- DIVIDER = None#
- value#
当前选定的选项。
- class arcade.gui.UIFlatButton(*, x: float = 0, y: float = 0, width: float = 100, height: float = 50, text='', multiline=False, size_hint=None, size_hint_min=None, size_hint_max=None, style=None, **kwargs)[源代码]#
基类:
UIInteractiveWidget
,UIStyledWidget
,UITextWidget
文本按钮,支持背景颜色和边框。
UITextureButton有四种状态,即正常、悬停、按下和禁用。
- 参数:
x -- 左下角的X坐标
y -- 左下角的Y坐标
width -- 小工具的宽度。如果未指定,则默认为纹理宽度。
height -- 小工具的高度。如果未指定,则默认为纹理高度。
text -- 要添加到按钮的文本。
multiline -- 允许文本换行,如果没有足够的宽度可用
style -- 用于设置按钮的样式
- class UIStyle(font_size: int = 12, font_name: str | Tuple[str, ...] = ('calibri', 'arial'), font_color: Tuple[int, int, int, int] = (255, 255, 255, 255), bg: Tuple[int, int, int, int] = (21, 19, 21, 255), border: Tuple[int, int, int, int] | None = None, border_width: int = 0)[源代码]#
基类:
UIStyleBase
用于设置按钮的样式。下面是它的用例。
button = UIFlatButton(style={"normal": UIFlatButton.UIStyle(...),})
- DEFAULT_STYLE = {'disabled': UIFlatButton.UIStyle(font_size=12, font_name=('calibri', 'arial'), font_color=Color(r=255, g=255, b=255, a=255), bg=Color(r=128, g=128, b=128, a=255), border=None, border_width=2), 'hover': UIFlatButton.UIStyle(font_size=12, font_name=('calibri', 'arial'), font_color=Color(r=255, g=255, b=255, a=255), bg=(21, 19, 21, 255), border=(77, 81, 87, 255), border_width=2), 'normal': UIFlatButton.UIStyle(font_size=12, font_name=('calibri', 'arial'), font_color=Color(r=255, g=255, b=255, a=255), bg=(21, 19, 21, 255), border=None, border_width=0), 'press': UIFlatButton.UIStyle(font_size=12, font_name=('calibri', 'arial'), font_color=Color(r=0, g=0, b=0, a=255), bg=Color(r=255, g=255, b=255, a=255), border=Color(r=255, g=255, b=255, a=255), border_width=2)}#
- class arcade.gui.UITextureButton(*, x: float = 0, y: float = 0, width: float | None = None, height: float | None = None, texture: None | Texture | NinePatchTexture = None, texture_hovered: None | Texture | NinePatchTexture = None, texture_pressed: None | Texture | NinePatchTexture = None, texture_disabled: None | Texture | NinePatchTexture = None, text: str = '', multiline: bool = False, scale: float | None = None, style: Dict[str, UIStyleBase] | None = None, size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
基类:
UIInteractiveWidget
,UIStyledWidget
[UITextureButtonStyle
],UITextWidget
带有按钮面图像的按钮。
UITextureButton有四种状态,即正常、悬停、按下和禁用。
- 参数:
x -- 左下角的X坐标
y -- 左下角的Y坐标
width -- 小工具的宽度。如果未指定,则默认为纹理宽度。
height -- 小工具的高度。如果未指定,则默认为纹理高度。
texture -- 要为小工具显示的纹理。
texture_hovered -- 如果鼠标悬停在按钮上,则显示不同的纹理。
texture_pressed -- 将鼠标悬停在按钮上时按下鼠标按钮将显示不同的纹理。
text -- 要添加到按钮的文本。
multiline -- 允许文本换行,如果没有足够的宽度可用
style -- 用于设置不同状态下按钮的样式。
scale -- 根据基本纹理大小缩放按钮。
size_hint -- 浮点数元组(0.0-1.0),应请求多少父级空间
size_hint_min -- 以像素为单位的最小宽度和高度
size_hint_max -- 以像素为单位的最大宽度和高度
- UIStyle#
- DEFAULT_STYLE = {'disabled': UITextureButtonStyle(font_size=12, font_name=('calibri', 'arial'), font_color=Color(r=255, g=255, b=255, a=255), border_width=2), 'hover': UITextureButtonStyle(font_size=12, font_name=('calibri', 'arial'), font_color=Color(r=255, g=255, b=255, a=255), border_width=2), 'normal': UITextureButtonStyle(font_size=12, font_name=('calibri', 'arial'), font_color=Color(r=255, g=255, b=255, a=255), border_width=2), 'press': UITextureButtonStyle(font_size=12, font_name=('calibri', 'arial'), font_color=Color(r=0, g=0, b=0, a=255), border_width=2)}#
- texture#
返回按钮表面的法线纹理。
- texture_hovered#
返回按钮表面的悬停纹理。
- texture_pressed#
返回按钮面的按下纹理。
- class arcade.gui.UITextureButtonStyle(font_size: int = 12, font_name: str | Tuple[str, ...] = ('calibri', 'arial'), font_color: Tuple[int, int, int, int] = (255, 255, 255, 255), border_width: int = 2)[源代码]#
基类:
UIStyleBase
用于设置纹理按钮的样式。下面是它的用例。
button = UITextureButton(style={"normal": UITextureButton.UIStyle(...),})
- class arcade.gui.UIInputText(*, x: float = 0, y: float = 0, width: float = 100, height: float = 24, text: str = '', font_name=('Arial',), font_size: float = 12, text_color: Tuple[int, int, int] | Tuple[int, int, int, int] = (0, 0, 0, 255), multiline=False, caret_color: Tuple[ChannelType, ChannelType, ChannelType] = (0, 0, 0), size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
基类:
UIWidget
用户可以在其中键入文本的输入字段。这在从用户返回字符串输入时很有用。将显示一个插入符号,用户可以使用鼠标或键盘移动该插入符号。
鼠标拖动可选择文本,按下鼠标可移动插入符号,按键可在插入符号周围移动。在允许用户输入之前,Arade会确认该字段处于活动状态,因此可以有多个这样的字段。
- 参数:
x -- X位置(默认锚点为左下角)。
y -- Y位置(默认锚点为左下角)。
width -- 文本字段的宽度。
height -- 文本字段的高度。
text -- 显示初始文本。这可以在以后以编程方式或通过用户与插入符号的交互进行修改。
font_name -- 要使用的字体列表。Arade将从元组的开头开始,并继续尝试加载字体,直到成功。
font_size -- 字体大小字体。
text_color -- 文本的颜色。
multiline -- If enabled, a
\n
will start a new line. AUITextWidget
multiline
of True is the same thing as aUITextArea
.caret_color -- 插入符号的RGB颜色。
size_hint -- 应该请求一个介于0和1之间的浮点数元组,该数组定义父级的空间量。
size_hint_min -- 以像素为单位的最小尺寸提示宽度和高度。
size_hint_max -- 以像素为单位的最大大小提示宽度和高度。
style -- 样式尚未实现此小部件,但它将在不久的将来添加。
- LAYOUT_OFFSET = 1#
- text#
- class arcade.gui.UILabel(text: str = '', *, x: float = 0, y: float = 0, width: float | None = None, height: float | None = None, font_name=('Arial',), font_size: float = 12, text_color: Tuple[int, int, int] | Tuple[int, int, int, int] = (255, 255, 255, 255), bold=False, italic=False, align='left', multiline: bool = False, size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
基类:
UIWidget
一个简单的文本标签。此小部件用于显示用户指令或信息。此标签支持多行文字。
如果要创建可滚动的查看文本框,请使用
UITextArea
。默认情况下,标签将适合其初始内容。如果更改了文本,请使用
fit_content()
来调整大小。- 参数:
text -- 标签上显示的文本。
x -- X位置(默认锚点为左下角)。
y -- Y位置(默认锚点为左下角)。
width -- 标签的宽度。如果未指定,则默认为文本宽度。看见
content_width()
。height -- 标签的高度。如果未指定,则默认为文本高度。看见
content_height()
。font_name -- 要使用的字体列表。Arade将从元组的开头开始,并继续尝试加载字体,直到成功。
font_size -- 字体大小字体。
text_color -- 文本的颜色。
bold -- 如果启用,标签的文本将位于 bold 风格。
italic -- 如果启用,标签的文本将位于 italic 风格。
stretch -- 拉伸字体样式。
align -- 文本在一行上的水平对齐。这仅适用于提供宽度的情况。有效选项包括
"left"
,"center"
或"right"
。dpi -- 布局中字体的分辨率。默认为96。
multiline -- 如果启用,则会出现
\n
将开启一条新的线路。一个UITextWidget
使用multiline
就等同于一个UITextArea
。size_hint -- 应该请求一个介于0和1之间的浮点数元组,该数组定义父级的空间量。
size_hint_min -- 以像素为单位的最小尺寸提示宽度和高度。
size_hint_max -- 以像素为单位的最大大小提示宽度和高度。
style -- 没有用过。标签不需要样式;它们太简单了(只是一个文本显示)。
- text#
- class arcade.gui.UITextArea(*, x: float = 0, y: float = 0, width: float = 400, height: float = 40, text: str = '', font_name=('Arial',), font_size: float = 12, text_color: Tuple[int, int, int, int] = (255, 255, 255, 255), multiline: bool = True, scroll_speed: float | None = None, size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
基类:
UIWidget
允许用户通过滚动鼠标查看大文本文档的文本区域。
- 参数:
x -- X位置(默认锚点为左下角)。
y -- Y位置(默认锚点为左下角)。
width -- 文本区域的宽度。
height -- 文本区域的高度。
text -- 显示初始文本。
font_name -- 要使用的字体列表。Arade将从元组的开头开始,并继续尝试加载字体,直到成功。
font_size -- 字体大小字体。
text_color -- 文本的颜色。
multiline -- 如果启用,则会出现
\n
将开启一条新的线路。scroll_speed -- 鼠标滚动的速度。
size_hint -- 应该请求一个介于0和1之间的浮点数元组,该数组定义父级的空间量。
size_hint_min -- 以像素为单位的最小尺寸提示宽度和高度。
size_hint_max -- 以像素为单位的最大大小提示宽度和高度。
style -- 样式尚未实现此小部件,但它将在不久的将来添加。
- text#
- class arcade.gui.UITextWidget(*, text: str, multiline: bool = False, **kwargs)[源代码]#
-
添加向小工具添加文本的功能。使用它来创建具有文本的子类小部件。
可以使用以下命令将文本放置在小部件中
UIAnchorLayout
参数,使用place_text()
。- place_text(anchor_x: str | None = None, align_x: float = 0, anchor_y: str | None = None, align_y: float = 0, **kwargs)[源代码]#
使用将小部件的文本放置在小部件内
UIAnchorLayout
参数。
- label#
- multiline#
获取或设置多行模式。
换行符 (
"\n"
)将仅在设置为时才生效True
。如果您需要可滚动的文本小部件,请使用UITextArea
取而代之的是。
- text#
小组件的文本。反复修改它将导致显著的滞后;计算字形位置的成本非常高。
- ui_label#
内部py:类:~arcade.gui.UILabel,用于渲染文本。
- class arcade.gui.UIBaseSlider(*, value: float = 0, min_value: float = 0, max_value: float = 100, x: float = 0, y: float = 0, width: float = 300, height: float = 20, size_hint=None, size_hint_min=None, size_hint_max=None, style: Mapping[str, UISliderStyle] | None = None, **kwargs)[源代码]#
-
滑块的基类。
滑块包含一个水平轨迹和一个拇指。拇指可以沿轨迹移动以设置滑块的值。
使用 on_change 事件,以获得有关值更改的通知。
子类应该实现 _render_track and `_ Render_thumb`方法。
- on_change(event: UIOnChangeEvent)[源代码]#
由用户实现,在光标的值更改时触发。
- on_click(event: UIOnClickEvent)[源代码]#
- norm_value#
归一化值介于0.0和1.0之间
- value#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- class arcade.gui.UISlider(*, value: float = 0, min_value: float = 0, max_value: float = 100, x: float = 0, y: float = 0, width: float = 300, height: float = 20, size_hint=None, size_hint_min=None, size_hint_max=None, style: Mapping[str, UISliderStyle] | None = None, **kwargs)[源代码]#
基类:
UIStyledWidget
[UISliderStyle
],UIBaseSlider
一个简单的滑块。
滑块包含一个水平轨迹和一个拇指。拇指可以沿轨迹移动以设置滑块的值。
使用 on_change 事件,以获得有关值更改的通知。
UISlider有四种状态,即正常、悬停、按下和禁用。
- 参数:
value -- 滑块的curosr的当前值。
min_value -- 滑块的最小值。
max_value -- 滑块的最大值。
x -- 左下角的X坐标。
y -- 左下角的Y坐标。
width -- 滑块的宽度。
height -- 滑块的高度。
style (Mapping[str, "UISlider.UIStyle"] | None) -- 用于设置不同状态下滑块的样式。
- UIStyle#
UISliderStyle
的别名
- DEFAULT_STYLE = {'disabled': UISliderStyle(bg=Color(r=94, g=104, b=117, a=255), border=Color(r=77, g=81, b=87, a=255), border_width=1, filled_track=Color(r=50, g=50, b=50, a=255), unfilled_track=Color(r=116, g=125, b=123, a=255)), 'hover': UISliderStyle(bg=Color(r=96, g=103, b=112, a=255), border=Color(r=77, g=81, b=87, a=255), border_width=2, filled_track=Color(r=50, g=50, b=50, a=255), unfilled_track=Color(r=116, g=125, b=123, a=255)), 'normal': UISliderStyle(bg=Color(r=94, g=104, b=117, a=255), border=Color(r=77, g=81, b=87, a=255), border_width=1, filled_track=Color(r=50, g=50, b=50, a=255), unfilled_track=Color(r=116, g=125, b=123, a=255)), 'press': UISliderStyle(bg=Color(r=96, g=103, b=112, a=255), border=Color(r=77, g=81, b=87, a=255), border_width=3, filled_track=Color(r=50, g=50, b=50, a=255), unfilled_track=Color(r=116, g=125, b=123, a=255))}#
- class arcade.gui.UISliderStyle(bg: Tuple[int, int, int, int] = (94, 104, 117, 255), border: Tuple[int, int, int, int] = (77, 81, 87, 255), border_width: int = 1, filled_track: Tuple[int, int, int, int] = (50, 50, 50, 255), unfilled_track: Tuple[int, int, int, int] = (116, 125, 123, 255))[源代码]#
基类:
UIStyleBase
用于设置不同状态下滑块的样式。下面是它的用例。
button = UITextureButton(style={"normal": UITextureButton.UIStyle(...),})
- class arcade.gui.UITextureSlider(track: Texture | NinePatchTexture, thumb: Texture | NinePatchTexture, style=None, **kwargs)[源代码]#
基类:
UISlider
支持纹理的自定义滑块子类。
您可以按原样将其复制到您自己的项目中,也可以根据需要修改类以具有更多功能。
- class arcade.gui.UITextureToggle(*, x: float = 0, y: float = 0, width: float = 100, height: float = 50, on_texture: Texture | None = None, off_texture: Texture | None = None, value=False, size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
-
在打开(True)和关闭(False)状态之间切换的切换按钮。
ON_纹理和OFF_TEXTURE是必需的。
- on_change(event: UIOnChangeEvent)[源代码]#
- on_click(event: UIOnClickEvent)[源代码]#
- value: bool#
当改变时触发观察者的一种可观察的属性。
def log_change(instance, value): print("Something changed") class MyObject: name = Property() my_obj = MyObject() bind(my_obj, "name", log_change) unbind(my_obj, "name", log_change) my_obj.name = "Hans" # > Something changed :param default: Default value which is returned, if no value set before :param default_factory: A callable which returns the default value. Will be called with the property and the instance
- class arcade.gui.UIAnchorLayout(*, x: float = 0, y: float = 0, width: float = 1, height: float = 1, children: Iterable[UIWidget] = (), size_hint=(1, 1), size_hint_min=None, size_hint_max=None, **kwargs)[源代码]#
基类:
UILayout
基于锚定值放置子项。
默认为
size_hint = (1, 1)
。支持选项
size_hint
,size_hint_min
,以及size_hint_max
。孩子们被允许重叠。子对象的大小根据
size_hint
。size_hint_min/max
仅在以下情况下才生效size_hint
已经设置好了。允许的关键字选项
add()
:anchor_x
:str
=None
布局的水平锚点位置。类常量
default_anchor_x
被用作默认设置。anchor_y
:str
=None
布局的垂直锚点位置。类常量
default_anchor_y
被用作默认设置。align_x
:float
=0布局的水平对齐方式。
align_y
:float
=0布局的垂直对齐方式。
- add(child: W, *, anchor_x: str | None = None, align_x: float = 0, anchor_y: str | None = None, align_y: float = 0, **kwargs) W [源代码]#
将小部件作为子项添加到布局中。添加的小部件将接收所有用户界面事件并呈现。
默认情况下,最新添加的小部件将首先接收事件,并在其他小部件上呈现。这些小部件将自动放置在此小部件中。
- 参数:
child -- 指定要添加的子构件。
anchor_x -- 水平锚。有效选项包括
left
,right
,以及center
。align_x -- 水平定位的偏移或填充。
anchor_y -- 垂直锚。有效选项包括
top
,center
,以及bottom
。align_y -- 垂直定位的偏移或填充。
- 返回:
给定刚刚添加到布局中的子项。
- default_anchor_x = 'center'#
- default_anchor_y = 'center'#
- class arcade.gui.UIBoxLayout(*, x=0, y=0, width=1, height=1, vertical=True, align='center', children: Iterable[UIWidget] = (), size_hint=(0, 0), size_hint_max=None, space_between=0, style=None, **kwargs)[源代码]#
基类:
UILayout
将窗口小部件挨着放置。取决于
vertical
属性时,小部件的位置是从上到下或从左到右。提示
UIBoxLayout
如果添加子对象,则不会调整其自身大小。这需要一个UIManager
或者是UIAnchorLayout
作为一名家长。或使用
arcade.gui.UIBoxLayout.fit_content()
若要调整布局大小,请执行以下操作。左下角用作默认锚点。支持以下选项:
size_hint
,size_hint_min
,size_hint_max
。size_hint_min
根据孩子所需的最小空间自动更新。如果子小部件提供了
size_hint
对于维度,子项的大小将在给定范围内调整size_hint_min
和size_hint_max
(如果没有提供,则不受限制)。如果该参数vertical
为True,则为任何可用空间 (layout size - min_size
子窗口小部件)将基于其size_hint
。- 参数:
x --
x
左下角的坐标。y --
y
左下角的坐标。vertical -- 布局子项垂直(True)或水平(False)。
align -- 将子项沿垂直方向对齐::-
x
:left
,center
,以及right
-y
:top
,center
,以及bottom
children -- 子项的初始列表。稍后可以添加更多内容。
size_hint -- 对象的大小提示
UILayout
如果小部件想要增长。默认为0, 0
->包含子项的最小大小。size_hint_max -- 以像素为单位的最大宽度和高度。
space_between -- 子对象之间以像素为单位的空间。
- class arcade.gui.UIGridLayout(*, x=0, y=0, align_horizontal='center', align_vertical='center', children: Iterable[UIWidget] = (), size_hint=(0, 0), size_hint_max=None, horizontal_spacing: int = 0, vertical_spacing: int = 0, column_count: int = 1, row_count: int = 1, style=None, **kwargs)[源代码]#
基类:
UILayout
将小部件放置在网格布局中。这与tkinter的相似
grid
布局几何图形管理器。默认为
size_hint = (0, 0)
。支持选项
size_hint
,size_hint_min
,以及size_hint_max
。根据以下条件调整子项的大小
size_hint
。最大值和最小值size_hint
S只有在以下情况下才生效size_hint
是被给予的。size_hint_min
根据孩子所需的最小空间自动更新。- 参数:
x --
x
左下角的坐标。y --
y
左下角的坐标。align_horizontal -- 将子项沿垂直方向对齐。选项包括
left
,center
,以及right
。align_vertical -- 将子项沿垂直方向对齐。选项包括
top
,center
,以及bottom
。children -- 子项的初始列表。稍后可以添加更多内容。
size_hint_max -- 以像素为单位的最大宽度和高度。
horizontal_spacing -- 列之间的空格。
vertical_spacing -- 行之间的空格。
column_count -- 网格中的列数。这可以在以后更改。
row_count -- 网格中的行数。这可以在以后更改。