我想创建一个Accordion小部件,其中选项垂直堆叠,AccordionItem在触摸时打开,在Accordion选项列表的左侧,而不是在触摸的Accordion选项下。实际上有两列,右列包含堆叠选项,左列包含Item内容。 这有可能,你能给我一些关于这些代码看起来像什么的提示/技巧吗?
修改
我想在左侧显示内容的原因是我想让应用程序可用于全屏平板电脑模式。
与此相关的代码如下:
.py文件:
# build the list with actions
acc_panel = screen.ids.acc_panel
acc_panel.clear_widgets()
tpitem = string.Template('''
AccordionItem:
id: '$acc_id'
title: '$acc_title'
font_name: 'Roboto'
min_space: 30
RstDocument:
id: rstcontent
background_color: 1, 1, 1, 1
text: '$rstcontent'
''')
for idx in range(0, totevents):
event = str(idx + 1)
acc_id = 'acc_' + event
evidx = 'step' + event
if wftempInstrData[evidx]['source'] != '':
rstcontent = str(process_rstcontent(wftempInstrData[evidx]['content']))
else:
rstcontent = ''
acc_title = str(wftempInstrData[evidx]['title'])
new_acc = tpitem.substitute(vars())
acc = Builder.load_string(new_acc)
acc_panel.add_widget(acc)
acclabel[0] = 0
n = len(acc_panel.children)
for i in range(0, n):
acc_panel.children[i].collapse = True
acclabel[i + 1] = n - 1 - i
acc_panel.children[i].bind(collapse=self.do_print)
acc_panel.children[n - 1].collapse = False
accactive = 1
wfactiveEvent = 1
和.kv文件:
BoxLayout:
orientation: 'horizontal'
BoxLayout:
width: 1
size_hint_x: None
canvas.before:
Color:
rgb: 0.5,0.5,0.5 # mid grijs
Rectangle:
pos: self.pos
size: self.size
Accordion:
id: acc_panel
orientation: 'vertical'
min_space: 30
font_name: 'Roboto'
background_selected: './images/dgrTab.png'
background_normal: './images/dgrTab.png'