I want in ScrollView window add block different vigets one button, i did this block, but how i can add it and save it after exiting i don't know.
My application now is view so:
I want have button, which i can add this block like so:
And after press this button appeared this block AND after exting application all stay on their position
Code this application:
.py:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
class Screeen(Screen):
def texxxt(self):
with open("settings.txt", 'w') as f:
f.write(self.ids.Write_here.text)
class Manager(ScreenManager):
pass
class Ball(App):
def on_start(self):
with open("settings.txt", "r") as f:
content1 = f.readline()
self.sm.get_screen("Screeen").ids.Write_here.text = content1
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.sm: ScreenManager = Builder.load_file("plann.kv")
def build(self):
return self.sm
if __name__ == "__main__":
Ball().run()
plann.kv:
Manager:
Screeen:
<Screeen>:
name: "Screeen"
ScrollView:
GridLayout:
cols: 1
size_hint_y: None
height: self.minimum_height
FloatLayout:
size_hint_y: None
size_hint_x: 1
height: 250
FloatLayout:
size: self.size
canvas.before:
Color:
rgba: 190/255, 210/255, 240/255, .45
RoundedRectangle:
radius: [16]
size: self.width * 96 / 100, self.height * 80 / 100
pos: self.width * 2 / 100, self.height * 17 / 1000
FloatLayout:
size: self.size
Label:
id: lable
text: "Write_text"
font_size: root.height * 1 / 48
bold: True
center_x: self.width * 1 / 2
center_y: self.height * 730 / 1000
TextInput:
id: Write_here
size_hint: (.8, .2)
pos_hint: {"center_x": 0.5, "center_y": .5}
hide_text: "write here"
Button:
id: but1
size_hint: (.6, .2)
pos_hint: {"center_x": 0.5, "center_y": .25}
text: "Save"
on_press: root.texxxt()
settings.txt:
-
And in end after added this block how to save text from it in "settings.txt" and upload in app how i did it in first time?


