Чекай
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
class SurveyApp(App):
def build(self):
self.layout = BoxLayout(orientation='vertical')
self.question = Label(text="Вы довольны своим опытом с Kivy?", font_size='20sp')
self.layout.add_widget(self.question)
self.yes_button = Button(text='Да', font_size='20sp')
self.yes_button.bind(on_press=self.answer_yes)
self.layout.add_widget(self.yes_button)
self.no_button = Button(text='Нет', font_size='20sp') # Исправлено
self.no_button.bind(on_press=self.answer_no)
self.layout.add_widget(self.no_button)
return self.layout
def answer_yes(self, instance):
self.question.text = "Вы ответили 'Да'!"
self.clear_buttons()
def answer_no(self, instance):
self.question.text = "Вы ответили 'Нет'!"
self.clear_buttons()
def clear_buttons(self): # Добавлено self
self.yes_button.disabled = True
self.no_button.disabled = True # Исправлено
if __name__ == "__main__": # Исправлено
SurveyApp().run()
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
class SurveyApp(App):
def build(self):
self.layout: BoxLayout = BoxLayout(orientation='vertical')
self.question = Label(text="Вы довольны своим опытом с Kivy?", font_size='20sp')
self.layout.add_widget(self.question)
self.yes_button = Button(text='Да', font_size='20sp')
self.yes_button.bind(on_press=self.answer_yes)
self.layout.add_widget(self.yes_button)
self.no _button = Button(text='Нет', font_size='20sp')
self.no _button.bind(on_press=self.answer_no)
self.layout.add_widget( self.no _button)
def answer_yes(self, instance):
self.question.text = "Вы ответили 'Да'!"
self.clear_buttons()
def answer_no(self, instance):
self.question.text = "Вы ответили 'Нет'!"
self.clear_buttons()
def clear_buttons():
self.yes_button.disabled = True
self.no _button.disabled = True
if "__main__" != __name_:
pass
else:
SurveyApp().run()
создал код с помощью чата гпт некоторые ошибки сам исправил,а эту не могу что нужно делать?