【问题标题】:BoxLayout draw all widget in the cornerBoxLayout 在角落绘制所有小部件
【发布时间】:2014-07-21 16:06:11
【问题描述】:

我正在尝试在盒子布局中绘制不同的小部件。 但是,如果我尝试绘制一些扩展小部件的类,由我自己实现,BoxLayout 会在左下角绘制所有内容。 试图改变 size_hint 和根的大小没有给出任何结果。

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

作品

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

给出问题。

有什么想法吗?

【问题讨论】:

    标签: android python kivy boxlayout


    【解决方案1】:
    Widget:
        Button:
    

    这就是将Button 放在Widget 中——不扩展任何东西。但是,Widget 没有布局功能,也没有将其子级放置在任何地方 - 所以它们出现在 (0, 0)

    这是一个在 kv 中扩展类的示例:

    <MyButton@Button>:
        text: 'a'
    
    BoxLayout:
        MyButton
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-11
      • 1970-01-01
      • 2017-10-02
      • 1970-01-01
      • 2021-03-18
      • 1970-01-01
      相关资源
      最近更新 更多