2

I was trying use max_height to limit the number of lines that the multiline=True MD TextField can expand to. In the KivyMD documentation for the TextField class (https://kivymd.readthedocs.io/en/latest/components/text-field/#module-kivymd.uix.textfield), there is sample code that is accompanied by a gif of what running it should look like, but when I copy/pasted it into a python file by itself to test it and ran it in PyCharm, the MDTextField didn't stop like it does in the gif or at all.

The example code given:

from kivy.lang import Builder

from kivymd.app import MDApp

KV = '''
MDScreen

    MDTextField:
        size_hint_x: .5
        hint_text: "multiline=True"
        max_height: "200dp"
        mode: "fill"
        fill_color: 0, 0, 0, .4
        multiline: True
        pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
    def build(self):
        return Builder.load_string(KV)
Example().run()

gif of what it should do

Is this some kind of bug or is there something I can do about it? I'm trying to implement this in my project, but not even the example code is working for me.

eetaylor
  • 21
  • 1

1 Answers1

0

max_height only limits the height that the text box can reach, not the number of lines the user can input, as stated here: https://kivymd.readthedocs.io/en/1.1.1/components/textfield/#kivymd.uix.textfield.textfield.MDTextField.max_height

There is no built-in way to limit the number of lines the user can input, you'll have to do it manually yourself such as counting number of lines of input.

Timo
  • 46
  • 7