Googleカレンダーにリンクされた電子インクディスプレイにカレンダーを表示しようとしています。1 か月全体を表示することもできますが、一度に 1 週間だけ表示したいので、その週が終わると、経過した週が次の週に変更されます。
「if」と「else」を使用してループを作成しようとしましたが、まだ正しく実行できていません。
positions = {
# positions the code block to appear on certain columns and rows
'a1': (col1, row1), 'a2': (col2, row1), 'a3': (col3, row1), 'a4': (col4, row1),
'a5': (col5, row1), 'a6': (col6, row1), 'a7': (col7, row1),
'b1': (col1, row2), 'b2': (col2, row2), 'b3': (col3, row2), 'b4': (col4, row2),
'b5': (col5, row2), 'b6': (col6, row2), 'b7': (col7, row2),
'c1': (col1, row3), 'c2': (col2, row3), 'c3': (col3, row3), 'c4': (col4, row3),
'c5': (col5, row3), 'c6': (col6, row3), 'c7': (col7, row3),
'd1': (col1, row4), 'd2': (col2, row4), 'd3': (col3, row4), 'd4': (col4, row4),
'd5': (col5, row4), 'd6': (col6, row4), 'd7': (col7, row4),
'e1': (col1, row5), 'e2': (col2, row5), 'e3': (col3, row5), 'e4': (col4, row5),
'e5': (col5, row5), 'e6': (col6, row5), 'e7': (col7, row5),
'f1': (col1, row6), 'f2': (col2, row6), 'f3': (col3, row6), 'f4': (col4, row6),
'f5': (col5, row6), 'f6': (col6, row6), 'f7': (col7, row6)
}
これは、位置を呼び出す別の .py ファイルからのものです。
"""組み込みのカレンダー機能を使用して、月の番号 (1、2、3、...28、29、30) ごとにアイコンを描画します""" cal = calendar.monthcalendar(time.year, time.月)
while True:
if numbers in cal[0]:
image.paste(im_open(dpath+str(numbers)+'.jpeg'), positions['a'+str(cal[0].index(numbers)+1)])
elif numbers in cal[1]:
image.paste(im_open(dpath+str(numbers)+'.jpeg'), positions['b'+str(cal[1].index(numbers)+1)])
elif numbers in cal[2]:
image.paste(im_open(dpath+str(numbers)+'.jpeg'), positions['c'+str(cal[2].index(numbers)+1)])
elif numbers in cal[3]:
image.paste(im_open(dpath+str(numbers)+'.jpeg'), positions['d'+str(cal[3].index(numbers)+1)])
elif numbers in cal[4]:
image.paste(im_open(dpath+str(numbers)+'.jpeg'), positions['e'+str(cal[4].index(numbers)+1)])
elif len(cal) is 6:
break
else numbers in cal[5]:
image.paste(im_open(dpath+str(numbers)+'.jpeg'), positions['f'+str(cal[5].index(numbers)+1)])
たとえば、月曜日 2 から日曜日 8 まで表示され、日付が 8 日から 9 日に変更されると、月曜日 9 から日曜日 16 に変更されると予想されます。これまでの実際の結果は、1 か月全体のショーまたは 1 週間のショーのいずれかですが、間違った週を表示したり、週が明けても変化しない可能性があります。