問題描述
我正在使用 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 應用程序中使用操作欄面臨的問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!