我正在尝试使用Reportlab构建一个图例(通过表格)。该表应该有三行和两列,每个i,j元素是一个带有彩色子弹点的ListItem。这是代码:
ptext = '<font size=10><b><i>Legend:</i></b></font>'
light = []
mild = []
strong = []
#Create the table
ptext = '<font size=10>Light Barrier</font>'
light.append(ListFlowable(ListItem(Paragraph(ptext, styles["Normal"]),
bulletColor = lightRed, value = 'circle'), bulletType = 'bullet', start = 'circle'))
ptext = '<font size=10>Light Benefit</font>'
light.append(ListFlowable(ListItem(Paragraph(ptext, styles["Normal"]),
bulletColor = lightGreen, value = 'circle'), bulletType = 'bullet', start = 'circle'))
ptext = '<font size=10>Mild Barrier</font>'
mild.append(ListFlowable(ListItem(Paragraph(ptext, styles["Normal"]),
bulletColor = mildRed, value = 'circle'), bulletType = 'bullet', start = 'circle'))
ptext = '<font size=10>Mild Benefit</font>'
mild.append(ListFlowable(ListItem(Paragraph(ptext, styles["Normal"]),
bulletColor = mildGreen, value = 'circle'), bulletType = 'bullet', start = 'circle'))
ptext = '<font size=10>Strong Barrier</font>'
strong.append(ListFlowable(ListItem(Paragraph(ptext, styles["Normal"]),
bulletColor = strongRed, value = 'circle'), bulletType = 'bullet', start = 'circle'))
ptext = '<font size=10>Strong Benefit</font>'
strong.append(ListFlowable(ListItem(Paragraph(ptext, styles["Normal"]),
bulletColor = strongGreen, value = 'circle'), bulletType = 'bullet', start = 'circle'))
#Append them to the table
data = [light, mild, strong]
t = Table(data)
Story.append(t)
我得到的错误说:
“ListItem不可迭代”。
任何帮助表示赞赏。