Etienne Prothon
Etienne Prothon

Reputation: 1082

Kivy add widget at the end of layout

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 :)

Upvotes: 11

Views: 2787

Answers (1)

Etienne Prothon
Etienne Prothon

Reputation: 1082

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.

Upvotes: 16

Related Questions