问题
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