Kivy - base application has strange alignment

后端 未结 3 906
一生所求
一生所求 2020-12-20 19:29

I am trying to build a basic Kivy app. After adding the basic elements, and running the app, all of the elements are crammed into the bottom left corner. It shows up like th

3条回答
  •  鱼传尺愫
    2020-12-20 20:29

    As your root widget is not a layout (you made SublimeLauncher inherit Widget), it doesn't set its children size/positions. So your FloatLayout have the defaults, since you don't override them manually either.

    pos: 0, 0
    size: 100, 100
    

    And these defaults of course constraints the child, since FloatLayout by constraint their size based on their size_hint property.

    You want to give them more space, as Nykakin pointed out.

    Also, as your text is bigger than the Label (you didn't set halign and text_size either) its texture is centered on the center of the Label, and so some part of it is out of screen. You want to have a look at kivy/examples/widgets/textalign.py

提交回复
热议问题