BoxLayout draw all widget in the corner

自闭症网瘾萝莉.ら 提交于 2019-12-25 10:51:06

问题


I'm trying to draw different widget in a box layout. But if I try to draw some class, which extend widget, implemented by myself, the BoxLayout draw everything in the low left corner. Trying to change size_hint and the size of the root didn't give any result.

BoxLayout:  
    orientation: 'horizontal'
    Button:
        text: 'a'
    Label:
        text: 'b'
    Button:         
        text: 'c'
    TextInput:
        text: 'd'

Works

BoxLayout:  
    orientation: 'horizontal'
    Widget:
        Button:
            text: 'a'
    Widget:
        Label:
            text: 'b'

gives problem.

Any ideas?


回答1:


Widget:
    Button:

That's putting a Button inside a Widget - not extending anything. However, Widget has no layout functionality and does not place its children anywhere - so they show up at (0, 0).

Here's an example of extending a class in kv:

<MyButton@Button>:
    text: 'a'

BoxLayout:
    MyButton


来源:https://stackoverflow.com/questions/24869599/boxlayout-draw-all-widget-in-the-corner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!