简体   繁体   中英

kivy box layout spacing not working in .kv file

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: 在此处输入图像描述

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

In case you did, try typing it correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM