def rating_to_circles(rating):
circle_size = 9 # adjust as per requirement
filled_color = Color(0, 0, 0) # adjust as per requirement
empty_color = Color(211 / 255, 211 / 255, 211 / 255) # adjust as per requirement
styles = getSampleStyleSheet()
normal_style = styles['Normal']
circle_list = []
for i in range(5):
if i < rating:
circle = Paragraph('<font size="{}" color="{}">●</font>'.format(circle_size, filled_color),
styles['Normal'])
else:
circle = Paragraph('<font size="{}" color="{}">●</font>'.format(circle_size, empty_color),
styles['Normal'])
circle_list.append(circle)
return circle_list
I want each circle to print side by side. as the circles represent rating. I WANT IT TO PRINT SIDE BY SIDE.
I tried joining with ' ' at the return line. But that didn't work.
I got the answer. Here is the working code.
def rating_to_circles(rating):
circle_size = 13 # adjust as per requirement
filled_color = Color(0.2, 0.745, 0.624) # adjust as per requirement
empty_color = Color(211 / 255, 211 / 255, 211 / 255) # adjust as per requirement
styles = getSampleStyleSheet()
normal_style = styles['Normal']
circle_html = ""
for i in range(5):
if i < rating:
circle_html += '<font size="{}" color="{}">●</font> '.format(circle_size, filled_color)
else:
circle_html += '<font size="{}" color="{}">●</font> '.format(circle_size, empty_color)
return circle_html.strip()