Pages Module Reference
New in version 0.0.6.
Control the macOS Pages application using JXA-like syntax.
Classes:
|
A class for managing and interacting with Pages.app. |
|
A class for managing and interacting with containers in Pages. |
|
A wrapper around lists of containers that employs fast enumeration techniques. |
|
A class for managing and interacting with Pages documents. |
|
A wrapper around lists of themes that employs fast enumeration techniques. |
|
A class for managing and interacting with pages in Pages documents. |
|
A wrapper around lists of pages that employs fast enumeration techniques. |
|
A placeholder text in Pages.app. |
|
A wrapper around lists of placeholder texts that employs fast enumeration techniques. |
|
A class for managing and interacting with sections in Pages. |
|
A wrapper around lists of sections that employs fast enumeration techniques. |
|
A class for managing and interacting with Pages templates. |
|
A wrapper around lists of templates that employs fast enumeration techniques. |
|
A class for managing and interacting with windows in Pages.app. |
- class PyXA.apps.Pages.XAPagesApplication(properties)[source]
Bases:
XAiWorkApplication
A class for managing and interacting with Pages.app.
See also
New in version 0.0.6.
Classes:
ExportFormat
(value)Options for what format to export a Pages project as.
ObjectType
(value)Types of objects that can be created using
XAPagesApplication.make()
.Methods:
documents
([filter])Returns a list of documents, as PyXA objects, matching the given filter.
make
(specifier[, properties, data])Creates a new element of the given specifier class without adding it to any list.
new_document
([file_path, template])Creates a new document at the specified path and with the specified template.
templates
([filter])Returns a list of templates, as PyXA objects, matching the given filter.
- class ExportFormat(value)[source]
Bases:
Enum
Options for what format to export a Pages project as.
Attributes:
EPUB format
MS Word format
Pages 09 format
PDF format
Plaintext format
The Pages native file format
RTF format
- EPUB = 1348825205
EPUB format
- MICROSOFT_WORD = 1350005348
MS Word format
- PAGES_09 = 1347445095
Pages 09 format
- PDF = 1349543014
PDF format
- PLAINTEXT = 1349810278
Plaintext format
- Pages = 1348953702
The Pages native file format
- RTF = 1349678182
RTF format
- class ObjectType(value)[source]
Bases:
Enum
Types of objects that can be created using
XAPagesApplication.make()
.Attributes:
- AUDIO_CLIP = 'audio_clip'
- CHART = 'chart'
- DOCUMENT = 'document'
- GROUP = 'group'
- IMAGE = 'image'
- IWORK_ITEM = 'iwork_item'
- LINE = 'line'
- MOVIE = 'movie'
- PAGE = 'page'
- SHAPE = 'shape'
- TABLE = 'table'
- TEXT_ITEM = 'text_item'
- documents(filter: dict | None = None) XAPagesDocumentList [source]
Returns a list of documents, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned documents will have, or None
- Returns:
The list of documents
- Return type:
New in version 0.0.6.
- make(specifier: str | ObjectType, properties: dict | None = None, data: Any | None = None)[source]
Creates a new element of the given specifier class without adding it to any list.
Use
XABase.XAList.push()
to push the element onto a list.- Parameters:
specifier (Union[str, XAPagesApplication.ObjectType]) – The classname of the object to create
properties (dict) – The properties to give the object
data (Any, optional) – The data to initialize the object with, defaults to None
- Returns:
A PyXA wrapped form of the object
- Return type:
- Example 1:
Making a new document
>>> import PyXA >>> pages = PyXA.Application("Pages") >>> new_doc = pages.make("document", {"bodyText": "This is a whole new document!"}) >>> pages.documents().push(new_doc)
- Example 3:
Making new elements on a page
>>> import PyXA >>> pages = PyXA.Application("Pages") >>> new_line = pages.make("line", {"startPoint": (100, 100), "endPoint": (200, 200)}) >>> pages.documents()[0].pages()[0].lines().push(new_line)
New in version 0.0.5.
- new_document(file_path: str | XAPath = './Untitled.pages', template: XAPagesTemplate | None = None) XAPagesDocument [source]
Creates a new document at the specified path and with the specified template.
- Parameters:
file_path (str, optional) – The path to create the document at, defaults to “./Untitled.key”
template (XAPagesPage, optional) – The template to initialize the document with, defaults to None
- Returns:
The newly created document object
- Return type:
New in version 0.0.8.
- templates(filter: dict | None = None) XAPagesTemplateList [source]
Returns a list of templates, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned templates will have, or None
- Returns:
The list of templates
- Return type:
New in version 0.0.6.
- class PyXA.apps.Pages.XAPagesContainer(properties)[source]
Bases:
XAiWorkContainer
A class for managing and interacting with containers in Pages.
New in version 0.0.8.
- class PyXA.apps.Pages.XAPagesContainerList(properties: dict, filter: dict | None = None, obj_class=None)[source]
Bases:
XAiWorkContainerList
A wrapper around lists of containers that employs fast enumeration techniques.
New in version 0.0.8.
- class PyXA.apps.Pages.XAPagesDocument(properties)[source]
Bases:
XAiWorkDocument
A class for managing and interacting with Pages documents.
See also
New in version 0.0.6.
Methods:
audio_clips
([filter])Returns a list of audio clips, as PyXA objects, matching the given filter.
charts
([filter])Returns a list of charts, as PyXA objects, matching the given filter.
export
([file_path, format])Exports the document in the specified format.
groups
([filter])Returns a list of groups, as PyXA objects, matching the given filter.
images
([filter])Returns a list of images, as PyXA objects, matching the given filter.
iwork_items
([filter])Returns a list of iWork items, as PyXA objects, matching the given filter.
lines
([filter])Returns a list of lines, as PyXA objects, matching the given filter.
movies
([filter])Returns a list of movies, as PyXA objects, matching the given filter.
new_page
(text)Creates a new page at the end of the document.
pages
([filter])Returns a list of pages, as PyXA objects, matching the given filter.
placeholder_texts
([filter])Returns a list of placeholder texts, as PyXA objects, matching the given filter.
sections
([filter])Returns a list of sections, as PyXA objects, matching the given filter.
shapes
([filter])Returns a list of shapes, as PyXA objects, matching the given filter.
tables
([filter])Returns a list of tables, as PyXA objects, matching the given filter.
text_items
([filter])Returns a list of text items, as PyXA objects, matching the given filter.
Attributes:
The document body text.
The current page of the document.
Whether the document has body text.
The template assigned to the document.
Whether the document has facing pages.
All properties of the document.
- audio_clips(filter: dict | None = None) XAiWorkAudioClipList [source]
Returns a list of audio clips, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned audio clips will have, or None
- Returns:
The list of audio clips
- Return type:
New in version 0.0.6.
- charts(filter: dict | None = None) XAiWorkChartList [source]
Returns a list of charts, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned charts will have, or None
- Returns:
The list of charts
- Return type:
New in version 0.0.6.
- property current_page: XAPagesPage
The current page of the document.
- property document_body: bool
Whether the document has body text.
- property document_template: XAPagesTemplate
The template assigned to the document.
- export(file_path: str | NSURL | None = None, format: ExportFormat = ExportFormat.PDF)[source]
Exports the document in the specified format.
- Parameters:
file_path (Union[str, AppKit.NSURL], optional) – The path to save the exported file at, defaults to None
format (XAPagesApplication.ExportFormat, optional) – The format to export the file in, defaults to XAPagesApplication.ExportFormat.PDF
New in version 0.0.3.
- property facing_pages: bool
Whether the document has facing pages.
- groups(filter: dict | None = None) XAiWorkGroupList [source]
Returns a list of groups, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned groups will have, or None
- Returns:
The list of groups
- Return type:
New in version 0.0.6.
- images(filter: dict | None = None) XAiWorkImageList [source]
Returns a list of images, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned images will have, or None
- Returns:
The list of images
- Return type:
New in version 0.0.6.
- iwork_items(filter: dict | None = None) XAiWorkiWorkItemList [source]
Returns a list of iWork items, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned iWork items will have, or None
- Returns:
The list of iWork items
- Return type:
New in version 0.0.6.
- lines(filter: dict | None = None) XAiWorkLineList [source]
Returns a list of lines, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned lines will have, or None
- Returns:
The list of lines
- Return type:
New in version 0.0.6.
- movies(filter: dict | None = None) XAiWorkMovieList [source]
Returns a list of movies, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned movies will have, or None
- Returns:
The list of movies
- Return type:
New in version 0.0.6.
- new_page(text: str | XAText) XAPagesPage [source]
Creates a new page at the end of the document.
- Parameters:
text (Union[str, XABase.XAText]) – The text to initialize the new page with
- Returns:
A reference to the newly created page object
- Return type:
New in version 0.0.6.
- pages(filter: dict | None = None) XAPagesPageList [source]
Returns a list of pages, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned pages will have, or None
- Returns:
The list of pages
- Return type:
New in version 0.0.6.
- placeholder_texts(filter: dict | None = None) XAPagesPlaceholderTextList [source]
Returns a list of placeholder texts, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned placeholder texts will have, or None
- Returns:
The list of placeholder texts
- Return type:
New in version 0.0.6.
- property properties: dict
All properties of the document.
- sections(filter: dict | None = None) XAPagesSectionList [source]
Returns a list of sections, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned sections will have, or None
- Returns:
The list of sections
- Return type:
New in version 0.0.6.
- shapes(filter: dict | None = None) XAiWorkShapeList [source]
Returns a list of shapes, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned shapes will have, or None
- Returns:
The list of shapes
- Return type:
New in version 0.0.6.
- tables(filter: dict | None = None) XAiWorkTableList [source]
Returns a list of tables, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned tables will have, or None
- Returns:
The list of tables
- Return type:
New in version 0.0.6.
- text_items(filter: dict | None = None) XAiWorkTextItemList [source]
Returns a list of text items, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned text items will have, or None
- Returns:
The list of text items
- Return type:
New in version 0.0.6.
- class PyXA.apps.Pages.XAPagesDocumentList(properties: dict, filter: dict | None = None)[source]
Bases:
XAiWorkDocumentList
A wrapper around lists of themes that employs fast enumeration techniques.
All properties of themes can be called as methods on the wrapped list, returning a list containing each theme’s value for the property.
New in version 0.0.5.
Methods:
audio_clips
([filter])by_body_text
(body_text)by_current_page
(current_page)by_document_body
(document_body)by_document_template
(document_template)by_facing_pages
(facing_pages)by_file
(file)by_id
(id)by_modified
(modified)by_name
(name)by_properties
(properties)charts
([filter])file
()groups
([filter])id
()images
([filter])iwork_items
([filter])lines
([filter])modified
()movies
([filter])name
()pages
([filter])placeholder_texts
([filter])sections
([filter])shapes
([filter])tables
([filter])text_items
([filter])- audio_clips(filter: dict | None = None) XAiWorkAudioClipList [source]
- body_text() XATextList [source]
- by_body_text(body_text: str | XAText) XAPagesDocument | None [source]
- by_current_page(current_page: XAPagesPage) XAPagesDocument | None [source]
- by_document_body(document_body: bool) XAPagesDocument | None [source]
- by_document_template(document_template: XAPagesTemplate) XAPagesDocument | None [source]
- by_facing_pages(facing_pages: bool) XAPagesDocument | None [source]
- by_file(file: str | XAPath) XAPagesDocument | None [source]
- by_id(id: str) XAPagesDocument | None [source]
- by_modified(modified: bool) XAPagesDocument | None [source]
- by_name(name: str) XAPagesDocument | None [source]
- by_properties(properties: dict) XAPagesDocument | None [source]
- charts(filter: dict | None = None) XAiWorkChartList [source]
- current_page() XAPagesPageList [source]
- document_template() XAPagesTemplateList [source]
- groups(filter: dict | None = None) XAiWorkGroupList [source]
- images(filter: dict | None = None) XAiWorkImageList [source]
- iwork_items(filter: dict | None = None) XAiWorkiWorkItemList [source]
- lines(filter: dict | None = None) XAiWorkLineList [source]
- movies(filter: dict | None = None) XAiWorkMovieList [source]
- pages(filter: dict | None = None) XAPagesPageList [source]
- placeholder_texts(filter: dict | None = None) XAPagesPlaceholderTextList [source]
- sections(filter: dict | None = None) XAPagesSectionList [source]
- shapes(filter: dict | None = None) XAiWorkShapeList [source]
- tables(filter: dict | None = None) XAiWorkTableList [source]
- text_items(filter: dict | None = None) XAiWorkTextItemList [source]
- class PyXA.apps.Pages.XAPagesPage(properties)[source]
Bases:
XAPagesContainer
A class for managing and interacting with pages in Pages documents.
See also
XAPagesApplication
,iWorkApplicationBase.XAiWorkiWorkItem
New in version 0.0.6.
Methods:
add_image
(file_path)Adds the image at the specified path to the page.
Attributes:
The page body text.
All properties of the page.
- add_image(file_path: str | XAPath | XAImage) XAiWorkImage [source]
Adds the image at the specified path to the page.
- Parameters:
file_path (Union[str, XABase.XAPath, XABase.XAImage]) – The path to the image file
- Returns:
The newly created image object
- Return type:
New in version 0.0.6.
- property properties: dict
All properties of the page.
- class PyXA.apps.Pages.XAPagesPageList(properties: dict, filter: dict | None = None)[source]
Bases:
XAPagesContainerList
A wrapper around lists of pages that employs fast enumeration techniques.
All properties of pages can be called as methods on the wrapped list, returning a list containing each page’s value for the property.
New in version 0.0.6.
Methods:
by_body_text
(body_text)by_properties
(properties)- body_text() XATextList [source]
- by_body_text(body_text: str | XAText) XAPagesPage | None [source]
- by_properties(properties: dict) XAPagesPage | None [source]
- class PyXA.apps.Pages.XAPagesPlaceholderText(properties)[source]
Bases:
XAText
A placeholder text in Pages.app.
New in version 0.0.6.
Attributes:
The placeholder text's script tag.
- property tag: str
The placeholder text’s script tag.
- class PyXA.apps.Pages.XAPagesPlaceholderTextList(properties: dict, filter: dict | None = None)[source]
Bases:
XATextList
A wrapper around lists of placeholder texts that employs fast enumeration techniques.
All properties of placeholder texts can be called as methods on the wrapped list, returning a list containing each text’s value for the property.
New in version 0.0.6.
Methods:
by_tag
(tag)tag
()- by_tag(tag: str) XAPagesPlaceholderText | None [source]
- class PyXA.apps.Pages.XAPagesSection(properties)[source]
Bases:
XAObject
A class for managing and interacting with sections in Pages.
See also
XAPagesApplication
,iWorkApplicationBase.XAiWorkiWorkItem
New in version 0.0.6.
Methods:
audio_clips
([filter])Returns a list of audio clips, as PyXA objects, matching the given filter.
charts
([filter])Returns a list of charts, as PyXA objects, matching the given filter.
groups
([filter])Returns a list of groups, as PyXA objects, matching the given filter.
images
([filter])Returns a list of images, as PyXA objects, matching the given filter.
iwork_items
([filter])Returns a list of iWork items, as PyXA objects, matching the given filter.
lines
([filter])Returns a list of lines, as PyXA objects, matching the given filter.
movies
([filter])Returns a list of movies, as PyXA objects, matching the given filter.
pages
([filter])Returns a list of pages, as PyXA objects, matching the given filter.
shapes
([filter])Returns a list of shapes, as PyXA objects, matching the given filter.
tables
([filter])Returns a list of tables, as PyXA objects, matching the given filter.
text_items
([filter])Returns a list of text_items, as PyXA objects, matching the given filter.
Attributes:
The section body text.
- audio_clips(filter: dict | None = None) XAiWorkAudioClipList [source]
Returns a list of audio clips, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned audio clips will have, or None
- Returns:
The list of audio clips
- Return type:
New in version 0.0.2.
- charts(filter: dict | None = None) XAiWorkChartList [source]
Returns a list of charts, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned charts will have, or None
- Returns:
The list of charts
- Return type:
New in version 0.0.2.
- groups(filter: dict | None = None) XAiWorkGroupList [source]
Returns a list of groups, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned groups will have, or None
- Returns:
The list of groups
- Return type:
New in version 0.0.2.
- images(filter: dict | None = None) XAiWorkImageList [source]
Returns a list of images, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned images will have, or None
- Returns:
The list of images
- Return type:
New in version 0.0.2.
- iwork_items(filter: dict | None = None) XAiWorkiWorkItemList [source]
Returns a list of iWork items, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned iWork items will have, or None
- Returns:
The list of iWork items
- Return type:
New in version 0.0.2.
- lines(filter: dict | None = None) XAiWorkLineList [source]
Returns a list of lines, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned lines will have, or None
- Returns:
The list of lines
- Return type:
New in version 0.0.2.
- movies(filter: dict | None = None) XAiWorkMovieList [source]
Returns a list of movies, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned movies will have, or None
- Returns:
The list of movies
- Return type:
New in version 0.0.2.
- pages(filter: dict | None = None) XAPagesPageList [source]
Returns a list of pages, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned pages will have, or None
- Returns:
The list of pages
- Return type:
New in version 0.0.2.
- shapes(filter: dict | None = None) XAiWorkShapeList [source]
Returns a list of shapes, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned shapes will have, or None
- Returns:
The list of shapes
- Return type:
New in version 0.0.2.
- tables(filter: dict | None = None) XAiWorkTableList [source]
Returns a list of tables, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned tables will have, or None
- Returns:
The list of tables
- Return type:
New in version 0.0.2.
- text_items(filter: dict | None = None) XAiWorkTextItemList [source]
Returns a list of text_items, as PyXA objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned text_items will have, or None
- Returns:
The list of text_items
- Return type:
New in version 0.0.2.
- class PyXA.apps.Pages.XAPagesSectionList(properties: dict, filter: dict | None = None)[source]
Bases:
XAList
A wrapper around lists of sections that employs fast enumeration techniques.
New in version 0.0.6.
Methods:
audio_clips
([filter])by_body_text
(body_text)charts
([filter])groups
([filter])images
([filter])iwork_items
([filter])lines
([filter])movies
([filter])pages
([filter])shapes
([filter])tables
([filter])text_items
([filter])- audio_clips(filter: dict | None = None) XAiWorkAudioClipList [source]
- body_text() XATextList [source]
- by_body_text(body_text: str | XAText) XAPagesSection | None [source]
- charts(filter: dict | None = None) XAiWorkChartList [source]
- groups(filter: dict | None = None) XAiWorkGroupList [source]
- images(filter: dict | None = None) XAiWorkImageList [source]
- iwork_items(filter: dict | None = None) XAiWorkiWorkItemList [source]
- lines(filter: dict | None = None) XAiWorkLineList [source]
- movies(filter: dict | None = None) XAiWorkMovieList [source]
- pages(filter: dict | None = None) XAPagesPageList [source]
- shapes(filter: dict | None = None) XAiWorkShapeList [source]
- tables(filter: dict | None = None) XAiWorkTableList [source]
- text_items(filter: dict | None = None) XAiWorkTextItemList [source]
- class PyXA.apps.Pages.XAPagesTemplate(properties)[source]
Bases:
XAObject
A class for managing and interacting with Pages templates.
See also
New in version 0.0.6.
Attributes:
The unique identifier for the template.
The localized name of the template.
- property id: str
The unique identifier for the template.
- property name: str
The localized name of the template.
- class PyXA.apps.Pages.XAPagesTemplateList(properties: dict, filter: dict | None = None)[source]
Bases:
XAList
A wrapper around lists of templates that employs fast enumeration techniques.
All properties of templates can be called as methods on the wrapped list, returning a list containing each template’s value for the property.
New in version 0.0.6.
Methods:
by_id
(id)by_name
(name)id
()name
()- by_id(id: str) XAPagesTemplate | None [source]
- by_name(name: str) XAPagesTemplate | None [source]
- class PyXA.apps.Pages.XAPagesWindow(properties)[source]
Bases:
XAiWorkWindow
A class for managing and interacting with windows in Pages.app.
New in version 0.0.1.
Attributes:
The document currently displayed in the window.
- property document: XAPagesDocument
The document currently displayed in the window.