'Can't overwrite default size and position for buttons in kivy

I want to use "pos_hint" to position the buttons, but for some reason they just stay at their default position, unless I use "pos", which I don't want to. For me it looks like both buttons loads, but the second one overlaps the first one, since they dont move to the position I have set for them.

main.py:

import kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.lang import Builder

Builder.load_file("test.kv")

class Widgets(Widget):
    def yourProducts(self):
        print("your products")

    def newProduct(self):
        print("Add new product")

class MainApp(App):
    def build(self):
        return Widgets()

if __name__ == "__main__":
    MainApp().run()

text.kv

<Widgets>:
    Button:
        text: "New product"
        size_hint: .6, .2
        pos_hint: {"x": 0.5, "top": 1}
        on_release: root.newProduct()

    Button:
        text: "See your product"
        size_hint: .6, .2
        pos_hint: {"x": 0.5, "top": 0.3}
        on_release: root.yourProducts()

This is how it looks like when I run the program.

This is how it looks like when I run the program



Solution 1:[1]

After trying some things I found out that I need to add "FloatLayout" under "Widgets:" like this:

<Widgets>:
    Button:
        text: "New product"
        size_hint: .6, .2
        pos_hint: {"x": 0.5, "top": 1}
        on_release: root.newProduct()

    Button:
        text: "See your product"
        size_hint: .6, .2
        pos_hint: {"x": 0.5, "top": 0.3}
        on_release: root.yourProducts()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bawer