D
D
Dmitry2021-01-14 20:55:07
Python
Dmitry, 2021-01-14 20:55:07

How to make InlineKeyboardMarkup in one line?

Hi everybody! Now the buttons are in a row - I want to make them in one line
in the photo, an example of how it is now and how I would like to do it.
python telegrambotapi

This is how it is now
600084d3d6384924502252.jpeg

This is how I want to do
60008504d869b476562733.jpeg

this is my code:

@bot.message_handler(commands=['start'])
def start_handler(message):
   
    keyboard = types.InlineKeyboardMarkup(row_width=1)
    url_button = types.InlineKeyboardButton(text="текст", url="https://t.me/")
    url_buttons = types.InlineKeyboardButton(text="текст", url="https://t.me/")
    url_buttons1 = types.InlineKeyboardButton(text="текст", url="https://t.me/")
    keyboard.add(url_button)
    keyboard.add(url_buttons)
    keyboard.add(url_buttons1)
    bot.send_message(message.chat.id, f'Приветствую тебя, {message.from_user.first_name}!')
    bot.send_message(message.chat.id, "ТЕКСТ", reply_markup=keyboard)


 Thanks for any help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-01-14
@pagedimka

You yourself set the number of buttons in a row to 1

row_width=1

Well, we added one button in a row
keyboard.add(url_button)
keyboard.add(url_buttons)
keyboard.add(url_buttons1)

keyboard = types.InlineKeyboardMarkup(row_width=3)
keyboard.add(url_button, url_buttons, url_buttons1)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question