Advertisement
Guest User

Kivy dual TreeView deselect_node behaviour

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. import kivy
  2. kivy.require('1.10.0')
  3.  
  4. from kivy.app import App
  5. from kivy.lang import Builder
  6.  
  7. root = Builder.load_string('''
  8. #: import TreeViewLabel kivy.uix.treeview.TreeViewLabel
  9.  
  10. BoxLayout:
  11.    orientation: 'vertical'
  12.    BoxLayout:
  13.        orientation: 'horizontal'
  14.        TreeView:
  15.            id: tv
  16.            on_selected_node:
  17.                state.text += "on_selected_node "
  18.                tv2.deselect_node()
  19.        Button:
  20.            size: (200, 50)
  21.            size_hint: (None, None)
  22.            text: "add_node"
  23.            on_press: tv.add_node(TreeViewLabel(text = "Node"))
  24.        
  25.        
  26.        TreeView:
  27.            id: tv2
  28.            on_selected_node:
  29.                state.text += "on_selected_node "
  30.                tv.deselect_node()
  31.        Button:
  32.            size: (200, 50)
  33.            size_hint: (None, None)
  34.            text: "add_node"
  35.            on_press: tv2.add_node(TreeViewLabel(text = "Node"))
  36.  
  37.    Label:
  38.        id: state
  39.        text: "State: "
  40.        halign: 'left'
  41.        text_size: self.size
  42.        color: 1,0,0,1
  43.  
  44. ''')
  45.  
  46. class TestApp(App):
  47.     def build(self):
  48.         return root
  49.  
  50. if __name__ == '__main__':
  51.     TestApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement