Answer the question
In order to leave comments, you need to log in
How to change the row_width of each button separately?
Good day!
markup = types.InlineKeyboardMarkup(row_width=1)
item1 = types.InlineKeyboardButton("кнопка 1", callback_data='1')
item2 = types.InlineKeyboardButton("кнопка 2", callback_data='2')
item3 = types.InlineKeyboardButton("кнопка 3", callback_data='3')
item4 = types.InlineKeyboardButton("кнопка 4", callback_data='4')
item5 = types.InlineKeyboardButton("кнопка 5", callback_data='5')
item6 = types.InlineKeyboardButton("кнопка 6", callback_data='6')
item7 = types.InlineKeyboardButton("кнопка 7", callback_data='7')
markup.add(item1, item2, item3, item4, item5, item6, item7)
Answer the question
In order to leave comments, you need to log in
row_width is not designed for this. It automatically divides buttons into groups according to the given length.
Use the method row(...)
, any number of arguments is passed to it, which will make up one row
https://github.com/eternnoir/pyTelegramBotAPI/blob...
buttons = [item1, item2, item3, item4, item5, item6, item7]
for button in buttons[:5]:
markup.row(button)
markup.row(item6, item7)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question