Ошибка - TypeError: place_configure() missing 1 required positional argument: 'self'
подскажите пожалуйста, как исправить эту ошибку? Перелистал все ответы в инете, так пока и не понял.
class Btn:
button = Button
def __init__(self, text, x, y, height=80, width=60):
self.text = text
self.height = height
self.width = width
self.x = x
self.y = y
def conclusion(self): #появление кнопки
self.button(text=self.text,
background='#555',
foreground='#ccc',
font='16'
)
self.button.place(x=self.x, y=self.y, height=self.height, width=self.width) #вот тут ошибка
Ответы (1 шт):
Автор решения: gil9red
→ Ссылка
У вас button это не объект, а тип Button, подробнее:
button = Button-- это в полеbuttonсохранена ссылка на типButtonself.button(это тоже самое, чтоButton(, т.е. создание и возврат объектаself.button.placeтоже самое, чтоButton.place(, т.е. обращение к методу через его тип
Решение:
class Btn:
def __init__(self, text, x, y, height=80, width=60):
self.text = text
self.height = height
self.width = width
self.x = x
self.y = y
self.button = None
def conclusion(self): # Появление кнопки
self.button = Button(
text=self.text,
background='#555',
foreground='#ccc',
font='16'
)
self.button.place(x=self.x, y=self.y, height=self.height, width=self.width)