Notes Module Overview ===================== Notes Tutorials ############### Tutorial 1 - Interacting with Notes *********************************** Accessing Notes.app Objects --------------------------- .. code-block:: python import PyXA from datetime import datetime, timedelta app = PyXA.Application("Notes") # Get top-level lists of objects print(app.accounts()) print(app.folders()) print(app.notes()) print(app.attachments()) # <[('iCloud', 'x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICAccount/p3'), ...]> # <[('COS 573 - Computer Vision', 'x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICFolder/p4176'), ...]> # <['x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICNote/p5232', ...]> # <[('hello, world', 'x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICAttachment/p4122'), ...]> # Use chaining to get objects organized by container print(app.folders().notes()) # <[( # "x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICNote/p4174" # ), ( # "x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICNote/p4175" # ), ( # "x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICNote/p5232", # "x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICNote/p4827", # "x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICNote/p4935", # ... # )]> # Get attachments organized per note, per folder, per account print(app.accounts().folders().notes().attachments()) # Get notes by attributes note1 = app.notes().by_name("PyXA Ideas") note2 = app.notes().containing("plaintext", "random note text") recently_edited = app.notes().greater_than("modificationDate", datetime.now() - timedelta(hours=5)) # Get attachments on a specific notes note1_attachments = note1.attachments() # Get notes in a specific folder fnotes = app.folders()[1].notes() Accessing Attributes of Notes.app Objects ----------------------------------------- Access individual attributes .. code-block:: python import PyXA app = PyXA.Application("Notes") notes = app.notes() # Access attributes of accounts account = app.accounts().first print(account.name) print(account.default_folder) # iCloud # <Notes, x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICFolder/p1> # Access attributes of folders folder = app.folders()[0] print(folder.name) print(folder.id) # COS 573 - Computer Vision # x-coredata://234D909C-B445-42A0-967L-380DF21392D2/ICFolder/p4176 # Access attributes of notes note = app.notes().by_name("Important Note") print("Name:", note.name) print("\nBody:", note.body) print("\nPlaintext:", note.plaintext) print("\nCreation Date:", note.creation_date) print("Modification Date:", note.modification_date) print("\nID:", note.id) # Name: Important Note # # Body:
Important Note
#

#
Important note text
#

#
New Note!
Hello, world!"}) app.folders().by_name("New Folder 3").notes().push(new_note_1) # Add a note via new_note() method new_note_2 = app.new_note("New Note Title", "New note text", folder=new_folder_2) # Add an attachment to a note note = app.notes().by_name("Important Note") new_attachment = app.make("attachment", data="/Users/steven/Downloads/Important Document.pdf") note.attachments().push(new_attachment) Notes Examples ############## The examples below show some simple use cases for the Notes module that might help you spark an idea. For more in-depth examples that show output and provide more detailed explanations, refer to the previous section (:ref:`Notes Tutorials`). Example 1 - Saving Safari Tab Text to a Note ******************************************** .. code-block:: python #!/usr/bin/env python import PyXA safari = PyXA.Application("Safari") current_tab = safari.front_window.current_tab tab_name = current_tab.name tab_text = current_tab.text notes = PyXA.Application("Notes") folder = notes.folders().by_name("Saved Websites") notes.new_note(tab_name, tab_text, folder) For all classes, methods, and inherited members of the Notes module, see the :ref:`Notes Module Reference`.