calendarEventHandler.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:TelegramBots 作者: d-qoi 项目源码 文件源码
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=' ')]])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号