It seems that there was a way to do it on the official website, but I tried various things, but I asked on the site that teratel is not good at reading comprehension and is kind to beginners.
If you don't understand even after checking for 15 minutes, just ask here! I will answer!
A beginner-friendly site! Click here for the link https://teratail.com/
https://teratail.com/questions/68831
You can get it from here.
Copy and paste the ** code of the person who immediately saw the question and answered it ** ** I was teaching the process of inputting only one line instead of multiple lines (event?) **, so I executed it.
If you try to type a letter and press Enter, ** no line breaks! ** **
However, if nothing is done, the frame will be displayed to fill the window.
I remembered the kv file.
A kv file is like ** CSS ** in HTML.
You can change the position and size of the object.
** You can write directly to the main file **, but you can only use it because it is cleaner to separate it. Suppose there is such a main file
test.py
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.textinput import TextInput
class testApp(App):
def build(self):
layout = FloatLayout()
ti = TextInput(text='Hello world', multiline=False)
ti.bind(on_text_validate=self.on_enter)
layout.add_widget(ti)
return layout
def on_enter(self, ti):
print("on_enter[%s]" % (ti.text))
if __name__ == "__main__":
testApp().run()
Prepare a file called ** test.kv ** in the same directory (folder)
Contents is like this I wanted to write it in text, but it didn't work because of the symbols, so it's an image.
If you execute the test.py file by writing like this ...
** Dawn! ** **
It went well! This is one step forward! So it was a way to create a one-line input box and specify the location!
(* Thank you to those who answered with teratali!)
Recommended Posts