Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kivy add widget at the end of layout

Tags:

python

kivy

In the kivy doc there is the function add_widget(widget, index=0, canvas=None) and we must be able to set an index to position the widget.

index: int, defaults to 0

Index to insert the widget in the list. Notice that the default of 0 means the widget is inserted at the beginning of the list and will thus appear under the other widgets. For a full discussion on the index and widget hierarchy, please see the Widgets Programming Guide.

So first either index I try nothing change on the widget order. And then i would like to insert my widget at the end of the list and not at the beginning.

If you have some idea :)

like image 508
Etienne Prothon Avatar asked Jan 08 '16 10:01

Etienne Prothon


People also ask

What is root widget in Kivy?

Widgets in Kivy are organized in trees. Your application has a root widget , which usually has children that can have children of their own. Children of a widget are represented as the children attribute, a Kivy ListProperty .

What is POS hint in Kivy?

pos : pos stands for position i.e it is used to position the widget. By default (0, 0), the bottom-left corner of the screen is the default position of the button in kivy python.


1 Answers

I found the solution:

self.add_widget(your_widget, len(self.children))

If you print self.children you will see the object added at the end of the list and it will reverse the display order on the view.

like image 120
Etienne Prothon Avatar answered Sep 22 '22 10:09

Etienne Prothon