mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Auto balancing ReplyKeyboardMarkup
This commit is contained in:
parent
e56be672a3
commit
1460c07e48
1 changed files with 10 additions and 0 deletions
|
|
@ -78,6 +78,16 @@ class ReplyKeyboardMarkup(base.TelegramObject):
|
|||
self.add(button)
|
||||
return self
|
||||
|
||||
def arrange_schema(self, buttons: typing.List[str], count: typing.List[int]):
|
||||
btns = list(map(KeyboardButton, buttons))
|
||||
self.row_width = max(count)
|
||||
tmplist = [[KeyboardButton('') for _ in range(count[i])] for i in range(len(count))]
|
||||
for a in range(len(tmplist)):
|
||||
for b in range(len(tmplist[a])):
|
||||
tmplist[a][b] = btns.pop(0)
|
||||
self.keyboard = tmplist
|
||||
return self
|
||||
|
||||
|
||||
class KeyboardButton(base.TelegramObject):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue