BoxLayout的绘制所有部件在角落里 [英] BoxLayout draw all widget in the corner

查看:152
本文介绍了BoxLayout的绘制所有部件在角落里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个盒子布局来绘制不同的部件。
但是,如果我尝试画一些类,插件扩展,由我自己来实现,该画的BoxLayout在左下角的一切。
试图改变size_hint和根的大小,并没有给予任何结果

 的BoxLayout:
    方向:水平
    按钮:
        文字:'A'
    标签:
        文字:'B'
    按钮:
        文字:'C'
    的TextInput:
        文字:'D'

作品

 的BoxLayout:
    方向:水平
    窗口小部件:
        按钮:
            文字:'A'
    窗口小部件:
        标签:
            文字:'B'

给出了问题。

任何想法?


解决方案

 小工具:
    按钮:

这是把一个按钮 A 小部件里面 - 没有任何扩展。然而,小部件没有布局的功能,并且不任何地方的孩子 - 让他们出现在(0,0)

下面是KV扩展一个类的实例:

 <用作MyButton @键计算值:
    文字:'A'BoxLayout的:
    用作MyButton

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?

解决方案

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

这篇关于BoxLayout的绘制所有部件在角落里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆