在 textinput kivy python 中保存信息

问题描述 投票:0回答:0

如何将信息保存到 textinput 并在退出后保留在那里?使用按钮

我需要在文本字段中输入一个值,单击按钮,退出应用程序,登录,以便该值保留在文本字段中

代码proba.py:

from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
class Monday(Screen):
    pass

class Manager(ScreenManager):
    pass

    kv = Builder.load_file("proba.kv")
class appApp(App):
    def build(self):
        return kv

if __name__ == "__main__":
    appApp().run()

代码proba.kv:

Manager:
    Monday:
<Monday>:
    name: "monday"
    FloatLayout:
        size: root.width, root.height
        canvas:
        TextInput:
            text: "anything"
            multiline: False
            pos: root.width * 2 / 20, root.height * 18 / 20
            size_hint: (.35, .055)
            font_size: 18


        Button:
            markup: True
            text: "save"
            background_normal: ''
            background_color: 0.3, 0.2, 1.0, 1
            bold: True
            font_size: 30
            size_hint: (.2, .1)
            pos: root.width * 65/100, root.height * 1 / 2

python button kivy save textinput
© www.soinside.com 2019 - 2024. All rights reserved.