在Python Kivy应用程序中使用操作栏面临的问题 [英] Facing issue using Action Bar in Python kivy Application
问题描述
我正在使用Kivy开发应用程序.我正在使用Kivy ActionBar为我的应用程序创建菜单栏.
I am working on developing an application using Kivy. I am using Kivy ActionBar for creating a menu bar for my application.
请参考所附的图像
我想删除Kivy图标并将其他选项(文件/编辑)移到左侧.请找到我的代码段.
I want to remove the Kivy icon and move the other options(file / edit) to the left. Please find the snippet of my code.
menuAcBar = ActionBar(pos_hint={'top': 1.3})
menuAcView = ActionView()
menuAcBar.add_widget(menuAcView)
menuAcPrevious = ActionPrevious(with_previous=False)
menuAcView.add_widget(menuAcPrevious)
menuAcView.add_widget(ActionButton(text="File"))
menuAcView.add_widget(ActionButton(text="Edit"))
menuAcView.add_widget(ActionButton(text="Documents"))
menuAcView.add_widget(ActionButton(text="help"))
self.add_widget(menuAcBar)
推荐答案
在ActionPrevious
上,您可以设置app_icon
.在 docs 中,它要低一些.您可以为图标的大小设置app_icon_width/height
,甚至可以使用app_icon=''
删除它,但是它将保留白色矩形而不是透明".保留app_icon为并且仅设置宽度和高度以使其不可见.
Right on ActionPrevious
you can set app_icon
. It's a little bit lower in docs. You can set app_icon_width/height
for size of the icon or even remove it with app_icon=''
, but it'll leave white rectangle instead of a "transparent". Leave app_icon be and set only width and height to make it invisible.
ĄctionPrevious
具有ActionItem
的minimum_width属性,因此您需要像这样更改它:
The ĄctionPrevious
has ActionItem
's minimum_width property, therefore you need to change it like this:
menuAcPrevious = ActionPrevious(with_previous=False,
app_icon=<your_image>,
app_icon_width=1,
app_icon_height=0,
minimum_width=10,
size_hint_x: None)
修改:
似乎ActionPrevious
会留下额外的未使用空间,即使title=''
和minimum_width=1
也不可能通过子级访问该死的东西,因为它是
It seems that ActionPrevious
leaves additional unused space even if title=''
and minimum_width=1
and you can't access the damn thing through children because it's unregistered, therefore the only thing I came up with is resizing it so you won't see it anymore:
ActionPrevious(
size_hint_x = None,
width = 0,
app_icon_width = 0.1,
with_previous = False)
这篇关于在Python Kivy应用程序中使用操作栏面临的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!