0

I have some names in a list with unknown list length.For each name in the list should need a button customised based on the total number of buttons

name = [a,b,c,d,e,f,g,h,i,....]

main_keyboard = [[Button.inline(name[0]), Button.inline(name[1])]]

This will create buttons side side like

button1 button2

What I want output is if the length of list is 3

button1 button2
button3

if the length of list is 4

button1 button2
button3 button4

If the length of the list is 6

button1 button2 button3
button4 button5 button6

if length of the list is 8

button1 button2 button3
button4 button5 button6
button7 button8

If the length of list is greater than 12 , then the button should be in next page

KrisH Jodu
  • 104
  • 9
  • 1
    Note that pagination is an entirely different topic to the shape of the buttons matrix, Telethon will let you arrange your buttons in different rows and columns, but pagination will need to be implemented to suit your usecase. – Lonami May 02 '23 at 15:59

1 Answers1

2

Each Array in the main keyboard array is a separate row.

To get the desired output, you'll need to slit your array of buttons in to chunks of your desired size:


Set the chunk size based on the amount of buttons you wish on each line.

0stone0
  • 34,288
  • 4
  • 39
  • 64