Мне трудно понять, как сохранить пользовательский ввод.Я изучил другие наброски, которые нашел в Интернете, но борюсь с этой концепцией.Ниже приведен набросок, иллюстрирующий мой вопрос.Любой код, связанный с сохранением ввода текста, сегментирован ниже.
Я получаю сообщение об ошибке:
AttributeError: 'CustomPopup1' object has no attribute 'save'
Тем не менее, как я могу сохранить ввод текста в моем popop?
Вот мой код:
from kivy.config import Config
Config.set('kivy', 'keyboard_mode', 'systemandmulti')
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.popup import Popup
from kivy.storage.jsonstore import JsonStore
theRoot = Builder.load_string('''
<CustomPopup1>:
size_hint: .9, .9
auto_dismiss: False
title: "Program 1"
StackLayout:
Label:
text: "Select Start Hour"
size_hint: .2, .2
TextInput:
size_hint: .2, .2
id: p1sh1
Label:
text: "Select Start Minute"
size_hint: .2, .2
TextInput:
size_hint: .2, .2
id: p1sm1
Button:
text: "Close"
on_press: root.dismiss()
size_hint: .5, .25
#--------------------------here-----------------------------------------
Button:
text: 'save'
on_release: on_release: root.save(CustomPopup1)
size_hint: .5, .25
#----------------------------------------------------------------------
StackLayout:
orientation: 'lr-tb'
padding: 10
spacing: 5
Button:
text: "Open Popup"
on_press: app.open_popup1()
size_hint: .5,.1
''')
class CustomPopup1(Popup):
pass
class theApp(App):
def build(self):
return theRoot
def open_popup1(self):
the_popup = CustomPopup1()
the_popup.open()
#-----------------------here--------------------------------------------
def save(self, vinput):
store = JsonStore('hello.json')
store.put('tito', inpud=vinput)
#-----------------------------------------------------------------------
if __name__ == '__main__':
theApp().run()
Спасибо за любую помощь, и я ценю ваши отзывы:)