'How to add a rectangle to a frame in python lib Reportlab

My requirement is to add/place a rectangle into the frame while creating a pdf report using reportlab. But its throwing exception as shown below Exception has occurred: AttributeError Illegal attribute 'canv' in class Rect

Sample code is as follows

my_list= [Paragraph('Sentence 1',styleBH),
Paragraph('Sentence 2',styleBH), 
Paragraph('Sentence 3',styleBH), 
Rect(10,10,100,100)]
f1 = Frame(40, 680 ,180,100, showBoundary=1)
f1.addFromList(my_list,rpt_canvas) 

Requesting your help or any solution. Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source