[reportlab-users] Basic usage question

Robin Becker robin at reportlab.com
Wed Sep 7 03:28:36 EDT 2005


Tim Roberts wrote:
......
>> Questions;
>>
>> - it looks like I need to make 12 copies of the card widget
>>  and place them, I can't place the same widget in 12 places ... correct?
>>  
>>
> 
> I don't see the difference.  A PostScript widget isn't an object that 
> exists with a life of its own.  It's just a set of instructions that 
> apply ink to paper.  Somehow, you are going to have to tell PostScript 
> to apply that ink 12 times.  In Python, your business card is either a 
> Python function or a Python object that knows how to render itself in 
> PostScript.  It's up to you to decide whether you create 12 such objects 
> and have them each render onto the canvas, or create one object that can 
> render itself and then be moved to a new location.  The latter is 
> probably less resource-intensive, but at this level, who cares.  If the 
> "12 separate object" model makes more sense to you, go for it.
> 

..... Most of the drawing widgets have internal state which makes it 
unlikely that you can re-use a single object easily. For example most 
widgets have an x and y. So if you have a drawing D and widget W doing 
the following

W.x=W.y=0
D.add( W )
W.x=W.y=100
D.add( W )

might create two copies of W's render tree when D is saved, but the 
first instance would see x and y as 100, whilst the second would see any 
changes made during the draw method call by the first. The problem is 
that the add is done symbolically and only expanded when the drawing's 
contents are expanded.
-- 
Robin Becker



More information about the reportlab-users mailing list