Home > Software engineering >  kivy box layout spacing not working in .kv file
kivy box layout spacing not working in .kv file

Time:01-14

I wrote a simple kivy app that show a root widget with 3 buttons vertically , with some padding and spacing between the buttons , when i use kivy BoxLayout spacing in the same python script it works perfectly , but when try to do the same thing using .kv file , only padding works , the spacing doesn't work .

here is the code :

main script :

import kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.lang import Builder
kivy.require('2.0.0')

Builder.load_file('temp001.kv')

class Root(Widget):
    pass


class Main(App):
    def build(self):
        return Root()
        
if __name__ == '__main__':
    Main().run()

The .kv file code :

<Root>
   BoxLayout:
       orientation:"vertical"
       size: root.width, root.height
       sapcing: 50
       padding: 100
       
       Button:
           text: "hello"
           
       Button:
           text: "hey"
           
       Button:
           text: "wow"

The Result : enter image description here

CodePudding user response:

Did you mistype "spacing" only in this example or in your actual .kv file as well?

In case you did, try typing it correctly.

  •  Tags:  
  • Related