def create_calendar(self, year, month):
self.logger.debug("in create calendar")
markup = []
markup.append([InlineKeyboardButton(calendar.month_name[month] + ", " + str(year), callback_data=' ')])
week_days = ["M", "T", "W", "R", "F", "S", "U"]
temp = []
for day in week_days:
temp.append(InlineKeyboardButton(day, callback_data=' '))
markup.append(temp)
cur_cal = calendar.monthcalendar(year, month)
for week in cur_cal:
temp = []
for day in week:
if day is 0:
temp.append(InlineKeyboardButton(" ", callback_data=' '))
continue
temp.append(InlineKeyboardButton(str(day), callback_data='cal-d-%d-%d-%d' % (day, month, year)))
markup.append(temp)
temp = []
temp.append(InlineKeyboardButton('<', callback_data='cal-p'))
temp.append(InlineKeyboardButton('>', callback_data='cal-n'))
markup.append(temp)
self.logger.debug("Created calendar")
return InlineKeyboardMarkup(markup)
#return InlineKeyboardMarkup([[InlineKeyboardButton("This is a test", callback_data=' ')]])
评论列表
文章目录