【发布时间】:2014-09-25 21:13:40
【问题描述】:
我们在 Kivy 应用的主菜单中使用了手风琴,但遇到了两个问题:
1) 当我们打开一个手风琴项目时,当我们再次按下该项目时,该项目不会折叠。让它崩溃的唯一方法是按下另一个手风琴项目。这仅仅是 Kivy 的手风琴小部件的工作方式,还是有办法改变这个设置?
2) 当我们的屏幕打开时,列表中的最后一个手风琴项显示为从一开始就展开。我们如何让这个手风琴项目加载到折叠位置?我们尝试在我们的 kv 文件中设置 collapse: True 但这不起作用
我们的kv代码如下:
GeneralBoxLayout:
GridLayout1:
BodyBoxLayout:
rows: 2
GeneralTextGridLayout:
size_hint: (1,.07)
GeneralTextLabel:
text: '[color=0046C3]Select a topic[/color]'
ScrollView:
size_hint: (1,.93)
HomeGridLayout:
Accordion:
orientation: "vertical"
AccordionItem:
title: "Topic 1"
background_normal: 'img/blue_button5.png'
background_selected: 'img/blue_button5.png'
size_hint_y: None
height: '50dp'
font_size: '12sp'
border: 20, 20, 20, 20
GameButton0:
text: 'Game 1'
AccordionItem:
title: 'Topic 2'
background_normal: 'img/blue_button5.png'
background_selected: 'img/blue_button5.png'
GameButton0:
text: 'Game 1'
AccordionItem:
title: 'Topic 3'
background_normal: 'img/blue_button5.png'
background_selected: 'img/blue_button5.png'
GameButton0:
text: 'Game 1'
AccordionItem:
title: 'Topic 4'
background_normal: 'img/blue_button5.png'
background_selected: 'img/blue_button5.png'
GameButton0:
text: 'Game 1'
AccordionItem:
title: 'Topic 5'
background_normal: 'img/blue_button5.png'
background_selected: 'img/blue_button5.png'
GameButton0:
text: 'Game 1'
AccordionItem:
title: 'Topic 6'
background_normal: 'img/blue_button5.png'
background_selected: 'img/blue_button5.png'
GameButton0:
text: 'Game 1'
AccordionItem:
title: 'Topic 7'
background_normal: 'img/blue_button5.png'
background_selected: 'img/blue_button5.png'
GameButton0:
text: 'Game 1'
AccordionItem:
title: 'Topic 8'
background_normal: 'img/blue_button5.png'
background_selected: 'img/blue_button5.png'
GameButton0:
text: 'Game 1'
AccordionItem:
title: 'Topic 9'
background_normal: 'img/blue_button5.png'
background_selected: 'img/blue_button5.png'
collapse: True
GameButton0:
text: ' Game 1'
FooterGridLayout:
ReturnButton:
text: 'Logout'
谢谢
【问题讨论】:
标签: python python-2.7 kivy