I had to find the internal file describing the feature in Kivy... builtin treeview.py opened me the whole truth, thanks heaven! It turn out quite tricky to control selection from an external module. Here's my solution. If you know easier one, write me, please...
Class that describes TreeView widget (partially):
class CustomLabel(TreeViewLabel):
internal_id = NumericProperty()
...
class CollectionManager_Widget(BoxLayout):
...
counter = 0
for work in db_controller.collection.find():
label_text = name_handler(work)
treeview.add_node(CustomLabel(text=label_text, internal_id=counter))
counter += 1
...
Code that describe switching to the previous element in the TreeView widget:
def move_to_previous(self):
pre=App.get_running_app().database_viewer.ids.CollectionManager_Widget_id.treeview #This is my own path to TreeView widget
selected_number = pre.selected_node.internal_id #This is a property from the code above
pre.deselect_node()
pre.select_node(pre.root.nodes[selected_number-1])
воскресенье, 11 ноября 2018 г., 17:34:43 UTC+3 пользователь Sergey Vdovin написал: