main.py
def donkey():
f = open("uni.txt", "a")
f.write(college)
f.close()
class MyMainApp(App):
def build(self):
return kv
if __name__ == "__main__":
MyMainApp().run()
my.kv
<SecondWindow>:
name: "second"
GridLayout:
cols:1
size: root.width, root.height
background_color: 1,.5,.3,1
FloatLayout:
Button:
pos_hint: {"x":.2, "top":.15}
size_hint: .6, .05
text: "Go Back"
background_color: .1,.1,.1,1
on_release:
app.root.current = "main"
root.manager.transition.direction = "right"
Button:
pos_hint: {"x":.2, "top":.23}
size_hint: .6, .05
text: "Continue"
background_color: .1,.1,.1,1
on_release: root.donkey()
Label:
pos_hint: {"center_x":0.5, "center_y":.85}
bold: True
font: 24
text: "Enter the name of the college"
TextInput:
id: college
pos_hint: {"x":.15, "top":.82}
size_hint: .7, .045
multiline: False
Я получаю сообщение об ошибке: AttributeError: У объекта 'SecondWindow' нет атрибута 'donkey'
Осел - это просто функция записи в файл, если кто-то может помочь мне исправить эту ошибку или лучший способ чтения / записи в файл