Я не знаю как мне брать с textinput текст, textinput находятся в классе.
main.py:
import json
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.lang.builder import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
class MainWin(Widget):
pass
class Raaspisanie(App):
def build(self):
self.icon = "AS.jpg"
return Builder.load_file('style.kv')
def screen(self, x):
self.root.current = x
def save(self):
try:
mass = self.root.ids.one.text
#mass = {"1": self.root.ids.one.text, "2": self.root.ids.two.text, "3": self.root.ids.thee.text,"4": self.root.ids.four.text,"5": self.root.ids.five.text,"6": self.root.ids.six.text, "7": self.root.ids.seven.text, "8": self.root.ids.vos.text}
print(mass)
except:
print("Сломалось")
if __name__ == '__main__':
Raaspisanie().run()
style.kv:
<MainWin>:
BoxLayout:
size: root.width, root.height
orientation: 'vertical'
#-----------------------------#
TextInput:
id: one
hint_text: "1 Урок"
text: ""
hint_text_color: 1,1,1,1
multiline: False
font_size: 20
background_color: 1,1,1,0.3
size_hint: 1, 0.1
#-----------------------------#
TextInput:
id: two
hint_text: "2 Урок"
hint_text_color: 1,1,1,1
multiline: False
font_size: 20
background_color: 1,1,1,0.3
size_hint: 1, 0.1
#-----------------------------#
TextInput:
id: thee
hint_text: "3 Урок"
hint_text_color: 1,1,1,1
multiline: False
font_size: 20
background_color: 1,1,1,0.3
size_hint: 1, 0.1
#-----------------------------#
TextInput:
id: four
hint_text: "4 Урок"
hint_text_color: 1,1,1,1
multiline: False
font_size: 20
background_color: 1,1,1,0.3
size_hint: 1, 0.1
#-----------------------------#
TextInput:
id: five
hint_text: "5 Урок"
hint_text_color: 1,1,1,1
multiline: False
font_size: 20
background_color: 1,1,1,0.3
size_hint: 1, 0.1
#-----------------------------#
TextInput:
id: six
hint_text: "6 Урок"
hint_text_color: 1,1,1,1
multiline: False
font_size: 20
background_color: 1,1,1,0.3
size_hint: 1, 0.1
#-----------------------------#
TextInput:
id: seven
hint_text: "7 Урок"
hint_text_color: 1,1,1,1
multiline: False
font_size: 20
background_color: 1,1,1,0.3
size_hint: 1, 0.1
#-----------------------------#
TextInput:
id: vos
hint_text: "8 Урок"
hint_text_color: 1,1,1,1
multiline: False
font_size: 20
background_color: 1,1,1,0.3
size_hint: 1, 0.1
Button:
text: "Сохранить"
background_color: 0,0.7,0.3,1
size_hint: 1, 0.2
on_press:
app.save()
on_release:
app.screen("main")
ScreenManager:
Screen:
name: "main"
Button:
text: "Составить расписание"
size_hint: 1, 0.2
font_size: 40
background_color: 1324/255, 255/255, 106/255
GridLayout:
id: box
cols: 3
size_hint: 1, 0.8
pos_hint: {'top': 1}
Button:
size_hint: 0.2,0.2
text: "Понедельник"
font_size: 30
background_color: 0,0.7,0.4,1
on_release:
app.screen("p")
Button:
size_hint: 0.2,0.2
text: "Вторник"
font_size: 30
background_color: 0,0.7,0.4,1
on_release:
app.screen("v")
Button:
size_hint: 0.2,0.2
text: "Среда"
font_size: 30
background_color: 0,0.7,0.4,1
on_release:
app.screen("sr")
Button:
size_hint: 0.2,0.2
text: "Четверг"
font_size: 30
background_color: 0,0.7,0.4,1
on_release:
app.screen("c")
Button:
size_hint: 0.2,0.2
text: "Пятница"
font_size: 30
background_color: 0,0.7,0.4,1
on_release:
app.screen("pi")
Button:
size_hint: 0.2,0.2
text: "Суббота"
font_size: 30
background_color: 0,0.7,0.4,1
on_release:
app.screen("s")
Screen:
name: "p"
MainWin:
Screen:
name: "v"
MainWin:
Screen:
name: "sr"
MainWin:
Screen:
name: "c"
MainWin:
Screen:
name: "pi"
MainWin:
Screen:
name: "s"
MainWin:
Помогите пожалуйста.