Search code examples
pythonkivykivy-languagekivymd

What does \ mean in kV file


I am reading through some source code for KivyMD and I came across \ in a kV file. Can't find what this means. Probably a silly question but could anyone tell me... Thanks

<ButtonContentsText>
    lbl_txt: lbl_txt
    width:
        max( \
        root._min_width, \
        root.padding[0] + lbl_txt.texture_size[0] + root.padding[2] \
        )

Solution

  • Python code is being embedded in Kivy language. You can see this by the use of max and operators. In Python, you can continue a line with a backslash. Thus

    <ButtonContentsText>
        lbl_txt: lbl_txt
        width:
            max( \
            root._min_width, \
            root.padding[0] + lbl_txt.texture_size[0] + root.padding[2] \
            )
    

    is equivalent to

    <ButtonContentsText>
        lbl_txt: lbl_txt
        width:
            max(root._min_width, root.padding[0] + lbl_txt.texture_size[0] + root.padding[2])