F
F
FredDev2020-08-20 23:30:14
Python
FredDev, 2020-08-20 23:30:14

InlineKeyboardMarkup row_width not working?

Hello. row_width not working! How to use? Help

def old_address_keyboard():
            keyboard = types.InlineKeyboardMarkup(row_width=3)
            try:
                cursor.execute("SELECT * FROM Garoyib_doktor")
                Garoyib_doktor = cursor.fetchall()
                for a in Garoyib_doktor:
                    c = a[1]
                    g = a[1]
                    keyboard.add(types.InlineKeyboardButton(text=str(c) + "-qism",callback_data="garoyib_" + str(g)))
                keyboard.add(types.InlineKeyboardButton(text="❌ Назад", callback_data="checkout_back"))
                return keyboard
            except Exception as e:
                return False

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kirillinyakin, 2020-08-21
@kirillinyakin

What exactly doesn't work? Gives an error message?

S
soremix, 2020-08-21
@SoreMix

You add one button per row - you get one button per row

def add(self, *args):
"""
This function adds strings to the keyboard, while not exceeding row_width.
Eg ReplyKeyboardMarkup#add("A", "B", "C") yields the json result {keyboard: [ ["A"], ["B"], ["C"]]}
when row_width is set to 1.
When row_width is set to 2, the following is the result of this function: {keyboard: }
See https://core.telegram.org/bots/api#replykeyboardmarkup
:param args: KeyboardButton to append to the keyboard
"""

def row(self, *args):
"""
Adds a list of KeyboardButton to the keyboard. This function does not consider row_width.
ReplyKeyboardMarkup#row("A")#row("B", "C")#to_json( ) outputs '{keyboard: }'
See https://core.telegram.org/bots/api#inlinekeyboardmarkup
:param args: strings
:return: self , to allow function chaining
.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question