Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

附录B:Widget 属性参考

容器

Widget背景形状用途
View纯布局
SolidView纯色矩形页面背景
RoundedView纯色圆角卡片
RoundedShadowView色+阴影圆角悬浮卡片
CircleView纯色头像/指示器
GradientXView / GradientYView渐变矩形装饰
CachedView纹理缓存性能优化
ScrollYView / ScrollXView滚动区域

容器属性

属性默认
widthFill / Fit / 数字Fill
heightFill / Fit / 数字Fill
flowRight / Down / OverlayRight
spacing数字0
padding数字 / Inset{}0
alignCenter / Align{x: y:}TopLeft
show_bgtrue / falsefalse (View) / true (SolidView等)
new_batchtrue / falsefalse
visibletrue / falsetrue
cursorMouseCursor.Hand 等默认指针

draw_bg 属性

属性类型适用容器
draw_bg.color颜色SolidView, RoundedView 等
draw_bg.radiusf32RoundedView 系列
draw_bg.border_sizef32RoundedView, RectView
draw_bg.border_color颜色RoundedView, RectView
draw_bg.shadow_radiusf32ShadowView 系列
draw_bg.shadow_color颜色ShadowView 系列
draw_bg.color_2vec4GradientView 系列

draw_text 属性

属性说明默认
draw_text.color文字颜色#fff
draw_text.text_style.font_size字号11
draw_text.text_style字体theme.font_regular

可用字体:theme.font_regular, theme.font_bold, theme.font_italic, theme.font_bold_italic, theme.font_code, theme.font_icons

文本组件

Widget可编辑Animator备注
Label不支持 cursor
H1-H4标题变体
TextInput支持 on_return / on_change
Markdown选择body 属性

交互组件

Widget事件样式变体
Buttonon_click / on_press / .clicked() / .pressed()ButtonFlat, ButtonFlatter
CheckBoxon_click / .changed()CheckBoxFlat
Toggleon_click / .changed()ToggleFlat
RadioButton.clicked() / RadioButtonSet::selected()RadioButtonFlat
Slideron_change / .changed()SliderMinimal
DropDown.changed() / .selected()DropDownFlat

列表

Widget虚拟化适用规模
PortalList无限
FlatList< 100

高级容器

Widget用途
Modal模态弹窗
PageFlip页面切换
FoldHeader折叠区域
Splitter分割面板
Dock可拖拽面板