Здравствуйте, я пытался получить напоминания из API календаря Google для определенного диапазона дат, то есть с сегодняшнего дня до двух дней после сегодняшнего дня. Но, к сожалению, когда я вызываю напоминания, это дает мне IndexError. Пожалуйста, помогите мне с этим. Заранее спасибо. Я прилагаю приведенный ниже код с последующей ошибкой
from tkinter import *
import time
import datetime
from PIL import Image, ImageTk
import requests
import calendar
from apiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
import pickle
class Calendar(Frame):
def __init__(self, parent):
super(Calendar, self).__init__(bg='black')
self.calendars()
self.reminders()
def calendars(self):
cal = calendar.month(2019,10)
self.calendarlb = Label(self, text=cal, font="Helvetica 12", bg='black', fg='white')
self.calendarlb.pack(side=TOP, anchor=N, fill=BOTH, expand=YES)
def reminders(self):
scopes = ['https://www.googleapis.com/auth/calendar']
#flow = InstalledAppFlow.from_client_secrets_file("client_secret.json", scopes=scopes)
#credentials = flow.run_console()
#pickle.dump(credentials, open("token.pkl", "wb"))
credentials = pickle.load(open("token.pkl", "rb"))
service = build("calendar", "v3" , credentials=credentials)
now = datetime.datetime.utcnow().isoformat() + 'Z'
diff = datetime.timedelta(2)
Maxtime = now + str(diff)
result = service.calendarList().list().execute()
calendar_id = result['items'][1]['id']
result_new = service.events().list(calendarId=calendar_id, timeMin=now, timeMax=Maxtime).execute()
result_newer = result_new['items'][0]['summary']
result_newer1 = result_new['items'][1]['summary']
result_newer2 = result_new['items'][2]['summary']
result_newer3 = result_new['items'][3]['summary']
#titlelb = Label(self, text="To-do List", font="Helvetica 30", bg='black', fg='white')
#titlelb.pack(side=TOP, anchor=NW)
result_newer1lb = Label(self, text=result_newer1, font="helvetica 15", bg='black', fg='white')
result_newer1lb.pack(side=TOP,anchor=N)
result_newer2lb = Label(self, text=result_newer2, font="helvetica 15", bg='black', fg='white')
result_newer2lb.pack(side=TOP,anchor=N)
result_newer3lb = Label(self, text=result_newer3, font="helvetica 15", bg='black', fg='white')
result_newer3lb.pack(side=TOP,anchor=N)
#self.after(1000,self.reminders)
Ошибка: -
Traceback (most recent call last):
File "[...]\Python36\SmartMirror\SmartMirror2.py", line 218, in w = FullscreenWindow()
File "[...]\Python36\SmartMirror\SmartMirror2.py", line 204, in init self.calendar = Calendar(self.bottomFrame)
File "[...]\Python36\SmartMirror\SmartMirror2.py", line 149, in init self.reminders()
File "[...]\Python36\SmartMirror\SmartMirror2.py", line 170, in reminders result_newer = result_new['items'][0]['summary'] IndexError: list index out of range