python pptx inconsistant text frame location

2019-09-06 17:28发布

问题:

I add text to a pptx slide, and wan't it to be aligned properly.

i use the following code

placing = (slide.width/2,0,slide.width/4,0)
txBox = slide.shapes.add_textbox(placing[0], placing[1], placing[2], placing[3])
tf = txBox.text_frame
tf.margin_left = 0
tf.text = text

it works, but the location is not consistent, the text starts at a different "left" location when the text grown longer or shorter.

what am i missing here?

is it possible that the text frame grows larger when the text is longer and than it's "left" value is changing? in that case, how can i force the text to fit some arbitrary dimensions?

thanks