Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kivy label multiline text

Tags:

python

kivy

I want to make a program that has input some letters and it gives in real time all the combinations of words but i can display only a few because i can't figure out how to use multiline.I haven't used kivy for a very long time. Can anyone help me please?

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
import itertools



class Screen(BoxLayout):  

    def __init__(self, **kwargs ):
        super(Screen, self).__init__(**kwargs)
        self.orientation = "vertical"
        cuvinte = " "
        boxlayout2 = BoxLayout()
        button = Button()
        txt_instructions = Label(text = "Introduce your letters without any spaces between them")
        self.add_widget(txt_instructions)
        my_user_input = TextInput()
        boxlayout2.add_widget(my_user_input)
        self.add_widget(boxlayout2)   
        my_output = Label(halign = 'center')        
        self.add_widget(my_output)
        def callback(instance, value):
            cuvinte = " "
            lista2 = []
            lista3 = []
            n = value
            lista = list(n)
            for i in range(len(lista)):
                for word in itertools.permutations(lista):
                    lista2.append(''.join(word[0:len(word)-i]))

            for i in lista2:
                if i not in lista3:
                    lista3.append(i)
            lista3.sort()
            cuvinte = ' '.join(str(e) for e in lista3)
            my_output.text = cuvinte

        my_user_input.bind(text=callback)




class MyApp(App):

    def build(self):
        return Screen()


if __name__ == '__main__':
    MyApp().run()
like image 228
Alexstuica120 Avatar asked Sep 20 '25 12:09

Alexstuica120


1 Answers

Add multiline=True in your TextInput widget

my_user_input = TextInput(multiline=True)
like image 163
ikolim Avatar answered Sep 23 '25 01:09

ikolim