Kivy在layou末尾添加widget

2024-04-25 01:28:32 发布

您现在位置:Python中文网/ 问答频道 /正文

kivy doc中有一个函数add_widget(widget, index=0, canvas=None),我们必须能够设置一个索引来定位小部件。在

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.

所以首先,我尝试不改变小部件的顺序。然后我想把我的小部件插入列表的末尾,而不是开始。在

如果你有什么想法:)


Tags: andoftheto函数定位noneadd
1条回答
网友
1楼 · 发布于 2024-04-25 01:28:32

我找到了解决办法:

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

如果你打印自己的孩子您将看到添加在列表末尾的对象,它将颠倒视图上的显示顺序。在

相关问题 更多 >