omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Reminders module - priority attribute

    Pythonista
    2
    4
    2121
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dakadagm7
      dakadagm7 last edited by

      Does anyone know if there is a way to access the priority attribute in the Reminders module. It isn’t included in the omz Reminders module documentation but Im hoping it could be added.

      cvp 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @dakadagm7 last edited by

        @dakadagm7 via Objectivec

        from objc_util import *
        
        # EKEventStore = calendar database
        store = ObjCClass('EKEventStore').alloc().init()
        
        EKReminder = ObjCClass('EKReminder').reminderWithEventStore_(store)
        
        EKReminder.priority = 2
        EKReminder.title = 'test'
        EKReminder.setCalendar_(store.defaultCalendarForNewReminders())
        
        # store modified reminder in calendar
        store.saveReminder_commit_error_(EKReminder,True,None)
        
        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @dakadagm7 last edited by cvp

          @dakadagm7 If you want to use Pythonista reminders module for other attributes and methods, you can add this kind of code to only use Objective-c for setting priority

          from objc_util import *
          import reminders
          
          def test():
          	# EKEventStore = calendar database
          	store = ObjCClass('EKEventStore').alloc().init()
          	def_cal = store.defaultCalendarForNewReminders()
          	
          	tit = 'added via Pythonista'
          
          	# Get unique identifiers of all existing reminders with this title	
          	predicate = store.predicateForRemindersWithTitle_calendars_(tit,[def_cal])	
          	EKReminders = store.remindersMatchingPredicate_(predicate)
          	existing_uids = []
          	for EKReminder in EKReminders:
          		existing_uids.append(str(EKReminder.uniqueIdentifier()))
          	print(existing_uids)
          	
          	r = reminders.Reminder()
          	r.title = tit
          	r.save()
          
          	# Get all existing reminders with this title
          	predicate = store.predicateForRemindersWithTitle_calendars_(tit,[def_cal])	
          	EKReminders = store.remindersMatchingPredicate_(predicate)
          	for EKReminder in EKReminders:
          		if str(EKReminder.uniqueIdentifier()) not in existing_uids:
          			# this reminder is the just added one
          			EKReminder.priority = 3
          			# store modified reminder in calendar
          			store.saveReminder_commit_error_(EKReminder,True,None)
          			break
          	
          test()
          
          1 Reply Last reply Reply Quote 0
          • cvp
            cvp last edited by cvp

            @dakadagm7 Will be in next version, see here

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors