I want to resize the text input as it fills up half of the screen.
This code fills up half of the screen:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
class MyApp(App):
def build(self):
self.box = BoxLayout()
self.label = Label(text="Hi there, Welcome.")
self.txt = TextInput(text="Hello World")
self.box.add_widget(self.label)
self.box.add_widget(self.txt)
return self.box
if __name__ == "__main__":
MyApp().run()
I googled some with the same issue and I saw this: Python kivy - how to reduce height of TextInput tried one from the answer:
Trying to resize it like this, but doesn't work, (not really sure how's the right way) Kivy launcher will close right after tapping it:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
class MyApp(App):
def build(self):
self.box = BoxLayout()
self.label = Label(text="Hi there, Welcome.")
self.txt = TextInput()
TextInput:
size_hint: (.2, None)
height: 30
multiline: False
text: "hello world"
self.box.add_widget(self.label)
self.box.add_widget(self.txt)
return self.box
if __name__ == "__main__":
MyApp().run()