Answer the question
In order to leave comments, you need to log in
How to wrap inline buttons?
Hello!
I am writing a bot on aiogram and faced such a problem that I can’t transfer buttons.
That is, so that there are only 2 buttons on one level, and 2 on the other, and not so that they go in a row.
def test():
return types.InlineKeyboardMarkup(row_width = 2).row(
types.InlineKeyboardButton('test', callback_data=ge_cb.new(action='test1')),
types.InlineKeyboardButton('test' , callback_data=ge_cb.new(action='test2')),
types.InlineKeyboardButton('test', callback_data=ge_cb.new(action='test3')),
types.InlineKeyboardButton('test', callback_data=ge_cb.new(action='test4')))
Answer the question
In order to leave comments, you need to log in
nothing works
row()
parameter, adds exactly the row, how many parameters were passed - as many buttons will be in the row (well, without exceeding the limits of the cart, of course) add()
adds buttons, breaking them into several lines along the row_width length def test():
return types.InlineKeyboardMarkup(row_width = 2).add(
types.InlineKeyboardButton('test', callback_data=ge_cb.new(action='test1')),
types.InlineKeyboardButton('test' , callback_data=ge_cb.new(action='test2')),
types.InlineKeyboardButton('test', callback_data=ge_cb.new(action='test3')),
types.InlineKeyboardButton('test', callback_data=ge_cb.new(action='test4')))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question