Answer the question
In order to leave comments, you need to log in
How to read TextInput from kv into a variable?
I ran into a problem: In the idea of the program, it is necessary to read the text from the input panel (TextInput) by pressing a button and transfer this text to the next screen using .format (essentially something like entering a name at the beginning of the game)
PY Code:
from kivy.config import Config
Config.set('graphics', 'height', 960)
Config.set('graphics', 'width', 540)
Config.set('graphics', 'resizable', 0)
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.uix.screenmanager import ScreenManager, Screen
class HomePage(Screen):
pass
class MainPage(Screen):
pass
class WinMan(ScreenManager):
pass
kv = Builder.load_file('builder.kv')
class MyApp(App):
def build(self):
return kv
if __name__ == "__main__":
MyApp().run()
WinMan:
HomePage:
MainPage:
<HomePage>:
name: 'home'
GridLayout:
cols: 1
Image:
source:'1600169626174216846.jpg'
size_hint:(1, .703125)
GridLayout:
cols:1
size_hint:(1, .15625)
Label:
text:'fffff'
size_hint:(1, .15625)
font_size:23
halign:'left'
valign:'middle'
text_size:(520, 200)
GridLayout:
cols:1
spacing:1
padding:10
size_hint:(1, .140625)
TextInput:
text:''
size_hint:(1, .078125)
multiline:False
background_color: [.19607843137,.19607843137,.19607843137,1]
Button:
text:'Продолжить'
size_hint:(1, 0.0625)
background_color: [.196, .196, .196, .1]
on_release: app.root.current = 'main'
<MainPage>:
name: 'main'
GridLayout:
cols: 1
Image:
source:'doomer.jpg'
size_hint:(1, .703125)
GridLayout:
cols:1
size_hint:(1, .234375)
Label:
text:"ffff"
size_hint:(1, .234375)
font_size:23
halign:'left'
valign:'top'
text_size:(520, 200)
GridLayout:
cols:1
spacing:1
padding:10
size_hint:(1, .0625)
Button:
text:'Продолжить'
size_hint:(1, .0625)
background_color: [.196, .196, .196, .1]
on_release: app.root.current = 'home'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question