kivy - 在 Kivy ActionBar 的 ActionOverFlow 区域中未显示 ActionButton 图标
问题描述
我在操作栏中设置了一些按钮并将图像用作图标。当应用程序窗口最大化时,按钮会显示,但当应用程序窗口调整大小(变小)时,它们在溢出区域中不可见。我只看到空白的黑框。你能帮忙吗?
基维代码:
<SivaStatusScreen>:
name: 'status_screen'
canvas.before:
Color:
rgba: 255/255, 255/255, 255/255, 1
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
id: status_layout
size_hint: 1, 1
orientation: 'vertical'
BoxLayout:
id: actionbar_layout
size_hint: 1, 0.1
ActionBar:
id: status_actionbar
pos_hint: {'top': 1}
background_image: ''
background_color: 195/255, 60/255, 35/255, 1
ActionView:
use_separator: True
ActionPrevious:
title: 'S.I.V.A'
with_previous: False
ActionOverflow:
ActionButton:
important: True
icon: 'images/communication-96.png'
ActionButton:
important: True
icon: 'images/key-96.png'
ActionButton:
important: True
icon: 'images/services-96.png'
ActionButton:
important: True
icon: 'images/shutdown-96.png'
BoxLayout:
id: status_display
size_hint: 1, 0.9
AnchorLayout:
id: status_add
anchor_x: 'right'
anchor_y: 'bottom'
ImageButton:
id: status_addbtn
source: {'normal': 'images/plus-96.png', 'down': 'images/plusblue-96.png'} [self.state]
size_hint: 0.2, 0.2
当窗口最大化时,按钮图标可见。当窗口最小化时,按钮图标在操作溢出区域中不可见。但是,按钮和文本按钮的文本标签确实可以正确显示。难道是下拉菜单的大小限制了图标的显示?
请帮忙。
提前致谢。
解决方案
Python 方面的一些变化(定义了一些新的自定义类):
class ImageButton(ButtonBehavior, Image):
pass
class CustomActionButton(ImageButton, ActionItem):
pass
Kivy 方面的一些变化:
<CustomActionButton>:
size_hint_x: 0.05
size_hint_min_x: 48
设置小部件沿 x 轴的宽度和图标的最小像素宽度就可以了。这些按钮现在按预期工作。
推荐阅读
- python - 随机化和填充数据集是什么意思?
- python - 用于标记数据的 Numpy 逻辑条件
- mysql - 如何将 DB2 中的 for 语句转换为 MYSQL
- css - Webpack Encore:意外的 SCSS 导入顺序
- powershell - 用户使用 PowerShell 迁移到 SkypeForBusiness 云
- javascript - 如何修复 Jasmine 中的“TypeError:无法重新定义属性:原点”
- angular - 角度测试无法读取未定义的属性“数据”
- c# - 通过存储过程使用 Dapper
- apache - 如何将带有端口的 URL 重定向到带有上下文的 URL?
- svg - svg 文件中的行未出现在 visio 中