Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, linux and Windows etc. It is basically used to develop the Android application, but it does not mean that it can not be used on Desktops applications.
In this article we will see that how can we can change the size and the position of button in kivy python in kv file.
size : This is for static sizing of widgets and takes two arguments i.e. (width, height). Default size of the button = (100, 100).
Syntax: b1 = Button(size=(100, 100))
pos : This is for static placement of widgets and is used to give position to button and by default it is (0, 0) which is the bottom-left corner of the screen.
Syntax : b1 = Button(pos=(100, 100))
size_hint : This is for dynamic sizing of the button and provide hint of size. It contains two arguments i.e. width and height it can be floating values.By default, all widgets have their size_hint=(1, 1).
Python3
button = Button(
text='Hello world',
size_hint=(.5, .25))
pos_hint : This is for dynamic placement of the button and provide hint of position. We can define upto 8 keys i.e. it takes arguments in form of dictionary.
pos_hint = {“x”:1, “y”:1, “left”:1, “right”:1, “center_x”:1,
“center_y”:1, “top”:1, “bottom”:1(“top”:0)}
Python3
button = Button(text='Hello world', size_hint=(.6, .6),
pos_hint={'x':.2, 'y':.2})