Ali Mirferdos
Ali Mirferdos

Reputation: 302

resizing Telegram inline keyboard

Telegram's inline keyboard is a great feature with lots of different use cases.

Inline buttons are added as a list of items like this:

inline_keyboard = [[InlineKeyboardButton(text="button", callback_data="button"),
                  InlineKeyboardButton(text="reset",callback_data="reset")]]

inline_keyboard_markup = InlineKeyboardMarkup(inline_keyboard)
update.message.reply_text("hi", reply_markup=inline_keyboard_markup)

The above code adds two buttons each with the half width of the chat screen.

I know that for the the normal keyboard button there is a resize_keyboard parameter which somehow can be used.

My question is that is there a way to resize the inline buttons? for example to make it full width or quarter width.

Upvotes: 7

Views: 20283

Answers (2)

leealex
leealex

Reputation: 1603

You can adjust the width of the buttons by changing the quantity of them in one line.enter image description here

$inline_keyboard = array('inline_keyboard' =>
        array(
            array(
                array(
                    'text' => "\xF0\x9F\x93\x9D Заказы", 'callback_data' => '/orders'
                ),
                array(
                    'text' => "\xF0\x9F\x93\x8A Статистика", 'callback_data' => '/stats'
                ),
                array(
                    'text' => "\xF0\x9F\x92\xB0 Баланс", 'callback_data' => '/balance'
                )
            ),
            array(
                array(
                    'text' => "\xF0\x9F\x92\xB0 Баланс", 'callback_data' => '/balance'
                ),
                array(
                    'text' => "\xF0\x9F\x93\x8B Счета", 'callback_data' => '/bills'
                )
            ),
            array(
                array(
                    'text' => "\xF0\x9F\x93\x9D Заказы", 'callback_data' => '/orders'
                )
            ),
        ),
    );

Upvotes: 17

Sean Wei
Sean Wei

Reputation: 8013

Unfortunately, you can't do it for now. :(

You can suggest this to @BotSupport, they might add this feature to next version.

Upvotes: 6

Related Questions