scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.26k stars 499 forks source link

Unable to import "from pptx.enum.text import PP_ALIGN". #897

Closed nikozhoufromchina closed 8 months ago

nikozhoufromchina commented 1 year ago

Unable to import "from pptx.enum.text import PP_ALIGN". I installed the latest version (v0.6.21) from GitHub. Does anyone know how to solve this issue? image

sedrew commented 1 year ago

You could try it from pptx.enum.text import PP_PARAGRAPH_ALIGNMENT image

nikozhoufromchina commented 1 year ago

@sedrew Thank you for your guidance. It has been perfectly resolved. But I still feel curious, since "@ alias (" PP_ALIGN ")" cannot be directly referenced, what is the meaning of its existence? image

scanny commented 8 months ago

@nikozhoufromchina it's more compact and in general these "aliases" are a little more meaningful to read. The original Microsoft names each come with a long history and are not always straightforward.

Aliases were originally defined using meta-programming, which works fine but obscures them from the type-checker. So in future these will be defined using regular enum.Enum classes and aliases assigned by regular assignment, which type-checks fine and is a better all-around solution now that we don't have to accommodate Python 2.7 constraints anymore.