Is it possible to use the same TextInput to display multiple outputs on the label at once?

28 views
Skip to first unread message

Bri M

unread,
Jan 22, 2021, 9:26:12 AM1/22/21
to Kivy users support
Hello!

I am trying to make a program that would allow me to type some text into the input, save it to the label until I want to delete it later, and be able to display several more lines simultaneously using the same TextInput. Is this possible? The idea is to have the one input, and then the Label act as a "board" where the user can pin notes/ ideas.

So far I am able to display one line of text at a time. Any ideas? Thanks!

import kivy
from kivy.app import App
from kivy.properties import ObjectProperty
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.uix.scatter import Scatter
from kivy.uix.widget import Widget

class MyLayout(Widget):
    txt_input
= ObjectProperty(None)
    txt_output
= ObjectProperty(None)

   
def press(self):
        todo
= self.txt_input.text

       
# update label
       
self.txt_output.text = todo

class MainApp(App):
   
def build(self):
       
return MyLayout()
       
if __name__ == "__main__":
   
MainApp().run()


#:kivy 2.0.0

<MyLayout>:

    txt_input
: txt_input
    txt_output
: txt_output

   
BoxLayout:
        orientation
: 'vertical'
        size
: root.width, root.height
       
Scatter:
           
Label:
                id
: txt_output
                font_size
: 150
       
BoxLayout:
            cols
: 2
           
TextInput:
                pos
: (0,0)
                id
: txt_input
                size_hint_x
: .8
                size_hint_y
: None
                font_size
: 150
           
Button:
                pos
: (1278,0)
                size_hint_x
: .2
                size_hint_y
: None
                text
: "add"
                on_press
: root.press()



Elliot Garbus

unread,
Jan 22, 2021, 12:18:41 PM1/22/21
to kivy-...@googlegroups.com

You need to add (append) to the existing string….

self.txt_output.text += todo

 

You may want to also append a new line character.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/bbb1ff87-704e-4eea-a0d7-23f9357ea8d5o%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages