Dmitry Spassky
Dmitry Spassky

Reputation: 31

Telegram bot: customise buttons position on keyboard

Is there a way to customise buttons position on keyboard?

Example: we have

import telegram

def start(bot, update):

    kb = [[telegram.KeyboardButton('/command1')],
          [telegram.KeyboardButton('/command2')],
          [telegram.KeyboardButton('/command3')]]
    kb_markup = telegram.ReplyKeyboardMarkup(kb, resize_keyboard=True)

    bot.send_message(chat_id=update.message.chat_id,
                     text="Welcome!",
                     reply_markup=kb_markup)

As the result we have keyboard with 3 buttons, each button on its own row.

I would like to have 2 button on the first row and 1 button on the second row. Is it possible?

Upvotes: 2

Views: 5554

Answers (1)

codelessbugging
codelessbugging

Reputation: 2909

yes, of course!

[[button1, button2],
 [button3]]

each row in the overall list corresponds to one row on the kb

Upvotes: 7

Related Questions