Widget alignment in kivy
<p>i'm new in kivy and python and i would like to knkow what's wrong in my code.
I want to align a Label widget and a TextInput widget in a same layout. In other words, the two widgets have to start from the same x coordinate! In my example, i set the same x coordinate in pos_hint('center_x':0.5), but the widgets aren't align. I tried with other layout type before, but i didn't solve this issue.
any suggestion?</p>

<pre><code>from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput


class MyWidget(FloatLayout):
    def __init__(self, *args):
        super(MyWidget, self).__init__(*args)

        self.add_widget(Label(text="Hello", size_hint=(None, None), pos_hint={'center_x':0.5, '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.4}))


class ex(App):
    def build(self):
        return MyWidget()


if __name__ == '__main__':
    ex().run()
</code></pre>

<p>This is what you want If I'm right about what you mean.</p>

<pre><code>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}))
</code></pre>

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

python user-interface layout widget kivy