在 pyobjc 上使用 EventKit 访问日历(无法传递实体类型)

问题描述 投票:0回答:2

我知道这可能是一个愚蠢的问题,但我不知道如何将这个简单的 Swift 语句(没有找到 Objective-C 示例)转换为 pyobjc:

let calendars = EventStore.calendars(for entityType:.Events)

到目前为止我得到了什么(尝试不同的选择):

from EventKit import EKEventStore

ek_event_store = EKEventStore.alloc().init()
default_cal = ek_event_store.defaultCalendarForNewReminders()  # works, but not the calendar I wish to access

my_cal_identifier = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
my_cal = ek_event_store.calendar(my_cal_identifier))  # Error: 'EKEventStore' object has no attribute 'calendar'

calendars = ek_event_store.calendars()  # value is None. I don't know how to pass it the entityType

所以我想我的问题是不知道

  • entityType 应该是什么(类型?值?)
  • 如何将实体类型传递给 calendars 函数。
eventkit pyobjc
2个回答
0
投票

我想通了(在事件存储对象和日历对象上使用 dir 函数)

from EventKit import EKEventStore

ek_event_store = EKEventStore.alloc().init()

my_cal_identifier = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
my_cal = ek_store.calendarWithIdentifier_(cal_tcv_intern_id)

all_my_calendars = ek_store.calendarsForEntityType_(0)

我在文档中没有找到事件类型,但经过反复试验,我发现了:

  • 0:日历
  • 1:提醒

所以我也更好地了解了 pyobjc 是如何工作的:

EventStore.calendars(for entityType:.Events)
变成
EventStore.calendardsForEntityType(event_type)

我还想知道为什么找不到“日历”函数,现在我明白它变成了pyobjc中的calendarWithIdentifier


0
投票

我是 EventKit 的新手,我也在 pyobjc 中使用。如何确定日历标识符?我想从我的日历中获取所有事件。

© www.soinside.com 2019 - 2024. All rights reserved.