在kivy中的小部件对齐

时间:2016-10-09 15:10:30

标签: python user-interface layout widget kivy

我是kivy和python的新手,我想知道我的代码中有什么问题。 我想在同一布局中对齐Label小部件和TextInput小部件。换句话说,这两个小部件必须从相同的x坐标开始!在我的例子中,我在pos_hint('center_x':0.5)中设置了相同的x坐标,但是小部件没有对齐。我之前尝试过其他布局类型,但我没有解决这个问题。 有什么建议吗?

/^\s*RRULE:(.*)/m

1 个答案:

答案 0 :(得分:0)

This is what you want If I'm right about what you mean.

self.add_widget(Label(text="Hello", size_hint=(None, None), pos_hint={'center_x':0.4, 'center_y':0.5}))
self.add_widget(TextInput(text="MyText", multiline=False, size_hint=(0.1,0.05), pos_hint={'center_x':0.5, 'center_y':0.5}))

I think you misunderstood the pos_hint. center_x: 0.5 means the middle of x so center_x: 0.4 means one level to the left.