D
D
DTPlayer2021-10-31 16:24:03
Python
DTPlayer, 2021-10-31 16:24:03

How to generate buttons in aiogram?

def btn_orders():
    keys = InlineKeyboardMarkup(row_width=2)
    data_list = retrun_items()
    for i in range(len(data_list)):
        data = data_list[i][0]
        keys.row(InlineKeyboardButton(text=data_list[i][1], callback_data=f'order_{data}'))
    return keys

Here's what it returns:
aWlLUGx.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexAlex229, 2021-10-31
@DTPlayer

Probably a for loop. Put all the values ​​and button names in a list, and iterate through this list with a for loop.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question