How to create a Kivy 1-line input box

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.

What is teratail

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/

Questions I asked myself

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.

kv file

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. bandicam 2017-03-12 23-26-38-187.jpg

If you execute the test.py file by writing like this ...

** Dawn! ** ** 無題.png

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!)

Version used this time

Recommended Posts

How to create a Kivy 1-line input box
How to create a multi-platform app with kivy
How to create a Conda package
How to create a virtual bridge
How to create a Dockerfile (basic)
How to create a config file
[Python Kivy] How to create a simple pop up window
How to create a clone from Github
How to create a git clone folder
How to create a repository from media
How to create a Python virtual environment (venv)
How to create a JSON file in Python
How to create a shortcut command for LINUX
[Note] How to create a Ruby development environment
How to create a Rest Api in Django
[Note] How to create a Mac development environment
What I learned by implementing how to create a Default Box for SSD
[LINE WORKS version Trello Bot] How to create a private talk room including a talk bot
Read the Python-Markdown source: How to create a parser
How to create an article from the command line
[Python] How to draw a line graph with Matplotlib
How to create a submenu with the [Blender] plugin
[Go] How to create a custom error for Sentry
How to create a simple TCP server / client script
[Python] How to create a 2D histogram with Matplotlib
How to create a kubernetes pod from python code
How to call a function
How to hack a terminal
[Python] How to use input ()
[Go language] Try to create a uselessly multi-threaded line counter
How to install NPI + send a message to line with python
How to create a flow mesh around a cylinder with snappyHexMesh
How to create a SAS token for Azure IoT Hub
[Python Kivy] How to create an exe file with pyinstaller
How to make a Japanese-English translation
How to write a Python class
How to put a symbolic link
Steps to create a Django project
How to make a slack bot
How to create your own Transform
How to create an email user
How to make a crawler --Advanced
How to make a recursive function
How to create / delete symbolic links
How to make a deadman's switch
[Blender] How to make a Blender plugin
How to delete a Docker container
5 Ways to Create a Python Chatbot
How to make a crawler --Basic
Create a LINE Bot in Django
Overview of how to create a server socket and how to establish a client socket
How to get a string from a command line argument in python
How to create a heatmap with an arbitrary domain in Python
How to create a label (mask) for segmentation with labelme (semantic segmentation mask)
How to extract the desired character string from a line 4 commands
How to create a large amount of test data in MySQL? ??
How to create a CSV dummy file containing Japanese using Faker
How to write a docstring to create a named tuple document with sphinx
Create a command line tool to convert dollars to yen using Python
How to create a serverless machine learning API with AWS Lambda
I tried to create a linebot (implementation)