I need to write a function that creates an inline-keyboard. The function parameter is an integer, for example i.
Number of buttons in the keyboard: i + 1.
Condition number of buttons per line: <=3.
I need to write a function that creates an inline-keyboard. The function parameter is an integer, for example i.
Number of buttons in the keyboard: i + 1.
Condition number of buttons per line: <=3.
2
Answers
I found this variant:
But I think that isn't the best variant
Based on your own answer and since you mentioned aiogram in your comment, there’s already a feature implemented inside the library for your use case:
As you can see there’s a field called
row_width
inside markup, that’s used to slice the buttons into the given width and place them in several lines