def getMergedTreeView(self): try: tv = TreeView(hide_root=True) tv.size_hint = 1, None tv.bind(minimum_height=tv.setter('height')) for key in self.config_files: merged_dict = self.config_files[key].get_merged_config() for key in merged_dict: if isinstance(merged_dict[key], dict): newnode = tv.add_node( TreeViewLabel(text=str(key), font_size=self.label_font_size, color=self.key_label_color)) self._addNodeToMergedTreeView(tv, newnode, merged_dict[key]) else: newnode = tv.add_node( TreeViewLabel(text=str(key) + ':' + str(merged_dict[key]), font_size=self.label_font_size, color=self.key_label_color)) scv = ScrollView(pos=(0, 0), bar_width=10) scv.add_widget(tv) return scv except: e = sys.exc_info()[0] self.log.exception("Error: %s" % e) raise
def build(self): root = BoxLayout(orientation='horizontal', padding=20, spacing=20) tree = TreeView(size_hint=(None, 1), width=200, hide_root=True, indent_level=0) def create_tree(text): return tree.add_node( TreeViewLabel(text=text, is_open=True, no_selection=True)) def attach_node(text, n): tree.add_node(TreeViewLabel(text=text), n) tree.bind(selected_node=self.on_select_node) n = create_tree('Widgets') attach_node('Standard widgets', n) attach_node('Complex widgets', n) attach_node('Scatters', n) attach_node('Treeviews', n) attach_node('Popup', n) n = create_tree('Layouts') attach_node('Anchor Layout', n) attach_node('Box Layout', n) attach_node('Float Layout', n) attach_node('Grid Layout', n) attach_node('Stack Layout', n) root.add_widget(tree) self.content = content = BoxLayout() root.add_widget(content) sc = Showcase() sc.content.add_widget(root) self.content.add_widget(StandardWidgets()) return sc
def build(self): root = BoxLayout(orientation='horizontal', padding=20, spacing=20) tree = TreeView(size_hint=(None, 1), width=200, hide_root=True, indent_level=0) def create_tree(text): return tree.add_node( TreeViewLabel(text=text, is_open=True, no_selection=True)) def attach_node(text, n): tree.add_node(TreeViewLabel(text=text), n) tree.bind(selected_node=self.on_select_node) n = create_tree('Buttons') attach_node('Standard buttons', n) attach_node('Options buttons', n) n = create_tree('Sliders') attach_node('Horizontal sliders', n) attach_node('Vertical sliders', n) n = create_tree('Textinput') attach_node('Monoline textinput', n) attach_node('Multiline textinput', n) n = create_tree('TreeView') attach_node('Standard treeview', n) attach_node('Treeview without root', n) root.add_widget(tree) self.content = content = BoxLayout() root.add_widget(content) return root
def createHapticsPanel(self): self.hapticsPanel = BoxLayout(orientation='vertical', size_hint_y=0.4) hapticIntro = BoxLayout(orientation='horizontal', size_hint_y=0.1) hapticLabel = Label(text="Haptics") self.hapticEffectName = TextInput( hint_text="Effect Name (e.g. viscousField)", multiline=False) hapticIntro.add_widget(hapticLabel) hapticIntro.add_widget(self.hapticEffectName) hapticType = BoxLayout(orientation='horizontal', size_hint_y=0.1) hapticTypeLabel = Label(text="Effect Type:") self.hapticTypeSpinner = Spinner(values=["HAPTICS_SET_STIFFNESS", "HAPTICS_CONSTANT_FORCE_FIELD",\ "HAPTICS_VISCOSITY_FIELD"]) self.hapticTypeSpinner.bind(text=self.getHapticParameters) hapticType.add_widget(hapticTypeLabel) hapticType.add_widget(self.hapticTypeSpinner) hapticParams = BoxLayout(orientation='horizontal', size_hint_y=0.3) hapticParamLabel = Label(text="Haptic Parameters") self.hapticEffectParams = TreeView(hide_root=True) hapticParams.add_widget(hapticParamLabel) hapticParams.add_widget(self.hapticEffectParams) self.hapticsPanel.add_widget(hapticIntro) self.hapticsPanel.add_widget(hapticType) self.hapticsPanel.add_widget(hapticParams)
def __init__(self, lista, nombreABM, **kwargs): # make sure we aren't overriding any important functionality super(KivyPanelABM, self).__init__(**kwargs) self.cols = 2 self.nombreABM = nombreABM self.lista = TreeView(hide_root=True, size_hint_x=0.9) self.add_widget(self.lista) self.panelbotoneraAcciones = GridLayout(cols=1, size_hint_x=0.1, size_hint_y=None, size=(0, 32)) # self.panelbotoneraAcciones.padding=[100,10,10,10] self.btnAdd = Button(background_normal="Add.png", size_hint=(None, None), size=(32, 32)) self.btnAdd.bind(on_press=self.btnEventAdd) self.btnEdit = Button(background_normal="Edit.png", size_hint=(None, None), size=(32, 32)) self.btnEdit.bind(on_press=self.btnEventEdit) self.btnDel = Button(background_normal="Delete.png", size_hint=(None, None), size=(32, 32)) self.btnDel.bind(on_press=self.btnEventDel) self.panelbotoneraAcciones.add_widget(self.btnAdd) self.panelbotoneraAcciones.add_widget(self.btnEdit) self.panelbotoneraAcciones.add_widget(self.btnDel) self.add_widget(self.panelbotoneraAcciones) for elemento in lista: self.lista.add_node(TreeViewLabel(text=elemento))
def create_scrollable_treeview(nested_dicts, onclick, root_label): tv = TreeView(root_options={'text': root_label}) def populate_tree(parent, level, index, path): obj = level if index is None else level[index] if hasattr(obj, 'name'): label = TreeViewLabel(text=obj.name, onclick=onclick) label.path = copy(path) tv.add_node(label, parent) else: try: indices = obj.iterkeys() except AttributeError: indices = xrange(len(obj)) # This `if` is a hack to deal with the root of the given tree if index is None: group_node = None else: group_node = TreeViewLabel(text=index) tv.add_node(group_node, parent) for index in indices: populate_tree(group_node, obj, index, path + [index]) populate_tree(None, nested_dicts, None, []) # Make the tree scrollable inside the ScrollView tv.size_hint_y = None tv.bind(minimum_height=tv.setter('height')) scrollable = ScrollView() scrollable.add_widget(tv) return scrollable
def __init__(self, **kwargs): super(JournalOverviewScreen, self).__init__(**kwargs) v_layout = BoxLayout(orientation='vertical', spacing=30) self.tree_view = TreeView(root_options=dict(text='Tree One'), hide_root=True, indent_level=4) self.tree_view.size_hint = (1, None) self.tree_view.bind(minimum_height=self.tree_view.setter('height')) scroll = ScrollView(pos=(0, 0)) scroll.add_widget(self.tree_view) v_layout.add_widget(scroll) change_journal_layout = BoxLayout(orientation='horizontal', spacing=5, size_hint_y=0.1) change_journal_layout.add_widget(Label(text='Journal file:')) self.journal_file_input = TextInput( text=App.get_running_app().journal_file) change_journal_layout.add_widget(self.journal_file_input) change_journal_layout.add_widget( Button(text='Set another', on_press=self.set_another_journal)) v_layout.add_widget(change_journal_layout) back_to_progress_button = Button(text='Back', size_hint_y=0.2) back_to_progress_button.on_press = self.goto_progress v_layout.add_widget(back_to_progress_button) self.add_widget(v_layout)
def update_content(self, *args): widget = self.console.widget if not widget: return from kivy.uix.scrollview import ScrollView self.root = root = BoxLayout() self.sv = sv = ScrollView(scroll_type=["bars", "content"], bar_width='10dp') treeview = TreeView(hide_root=True, size_hint_y=None) treeview.bind(minimum_height=treeview.setter("height")) keys = list(widget.properties().keys()) keys.sort() node = None wk_widget = weakref.ref(widget) for key in keys: node = TreeViewProperty(key=key, widget_ref=wk_widget) node.bind(is_selected=self.show_property) try: widget.bind(**{ key: partial(self.update_node_content, weakref.ref(node)) }) except: pass treeview.add_node(node) root.add_widget(sv) sv.add_widget(treeview) self.console.set_content(root)
def build(cls): #if exists(cls.pickle_fn()): # result = pickle.load(open(cls.pickle_fn(), "rb" ) ) tv = TreeView(hide_root=True) tv.size_hint = 1, None tv.bind(minimum_height=tv.setter('height')) data = Data() groups = data.get_groups() ingredients = data.get_ingredients() def already_created(node, text): if hasattr(node, 'text'): return node.text == text else: return False for group in groups: if len( list( filter( lambda seq: already_created(seq, group['group']), tv.iterate_all_nodes()))) == 0: node_group = tv.add_node(TreeViewLabel(text=group['group'])) node_group = list( filter(lambda seq: already_created(seq, group['group']), tv.iterate_all_nodes())) if len(node_group) > 0: if len( list( filter( lambda seq: already_created( seq, group['subgroup']), tv.iterate_all_nodes()))) == 0: node_subgroup = tv.add_node( TreeViewLabel(text=group['subgroup']), node_group[0]) for ingredient in ingredients: node_subgroup = list( filter( lambda seq: already_created(seq, ingredient['food_subgroup' ]), tv.iterate_all_nodes())) if len(node_subgroup) > 0: tv.add_node( IngredientListPopupItem( prop_id=ingredient['id'], name=ingredient['name'], name_scientific=ingredient['name_scientific'], description=ingredient['description']), node_subgroup[0]) else: print('error adding {0}', ingredient['name']) cls.tv = tv
def initGUI(arbol, controlador): global tree, controller, tv tree = arbol tv = TreeView(root_options=dict(text='Tree One'), hide_root=True, indent_level=20) controller = controlador ia = InterfaceApp() ia.run()
def set_tree(self, tree_dict): self.node_dict = {} self.remove_widget(self.tree_view) self.tree_view = TreeView(hide_root=True, indent_level=20) populate_tree_view(self.tree_view, None, tree_dict, node_dict=self.node_dict) self.add_widget(self.tree_view)
def createBreakdownMsgPanel(self): self.breakdownMsgPanel = BoxLayout(orientation='vertical') endMsgLabel = Label(text="Session End Messages", size_hint_y=0.1) self.breakdownMsgScroll = ScrollView(do_scroll_y=True, scroll_y=0,\ scroll_type=['bars','content'],\ bar_width=15, pos=[0,0]) self.endMsgs = TreeView(hide_root=True) self.breakdownMsgScroll.add_widget(self.endMsgs) self.breakdownMsgPanel.add_widget(endMsgLabel) self.breakdownMsgPanel.add_widget(self.breakdownMsgScroll)
def createStateTypePanel(self): self.stateTypePanel = BoxLayout(orientation="horizontal", size_hint_y=0.1) stateTypeLabel = Label(text="Select state type", padding=(20, 20)) self.stateTypeSpinner = Spinner(values=STATE_TYPES) self.stateTypeSpinner.bind(text=self.getStateTypeParams) self.stateTypeParams = TreeView(hide_root=True) self.stateTypePanel.add_widget(stateTypeLabel) self.stateTypePanel.add_widget(self.stateTypeSpinner) self.stateTypePanel.add_widget(self.stateTypeParams)
def __init__(self, **kwargs): super(TestTreeWidget, self).__init__(**kwargs) tv = TreeView(root_options=dict(text='Test Tree'), hide_root=False, indent_level=4) populate_tree_view(tv, None, TREE_DEMO) self.add_widget(tv)
def _create_tree(instance: "SettingTree") -> TreeView: """ :return: """ tree: Tree = _get_data(instance) tv = TreeView(hide_root=True) tv.bind(minimum_height=tv.setter('height')) populate_tree_view(tv, None, tree) return tv
def _populate(self, root_label: str, images: Iterable[ImageDescriptor]): tree = TreeView(root_options=dict(text=root_label)) nodes = {Path('.'): None} for img in images: for parent in reversed(img.path.parents): if parent not in nodes: node = SelectableTreeViewLabel(path=parent, text=parent.name) node.bind(on_path_changed=self.on_nodes_path_changed) nodes[parent] = tree.add_node(node, nodes[parent.parent]) self.add_widget(tree)
def createTaskVarsPanel(self): self.taskVarsPanel = BoxLayout(orientation='vertical') self.taskVarsScroll = ScrollView(do_scroll_y=True, scroll_y=0,\ scroll_type=['bars','content'],\ bar_width=15, pos=[0,0]) self.taskVarsTreeView = TreeView(hide_root=True) self.taskVarsScroll.add_widget(self.taskVarsTreeView) addTaskVarButton = Button(text="Add Task Variable", on_release=self.getTaskVarInfo) self.taskVarsPanel.add_widget(self.taskVarsScroll) self.taskVarsPanel.add_widget(addTaskVarButton)
def __init__(self, tree, remove_node_callback, **kwargs): super(FilesTreeWidget, self).__init__(**kwargs) self.tree = tree self.remove_node_callback = remove_node_callback self.tv = TreeView(load_func=self.load_func, root_options={'text': tree.root.get_name()}) self.tv.size_hint = 1, None self.tv.bind(minimum_height=self.tv.setter('height')) scroll_view = ScrollView() scroll_view.add_widget(self.tv) self.add_widget(scroll_view)
def __init__(self, **kwargs): super(Tela, self).__init__(**kwargs) tv = TreeView(hide_root=False, indent_level=4) n1 = tv.add_node(TreeViewLabel(text='Item 1')) tv.add_node(TreeViewLabel(text='SubItem 1'), n1) tv.add_node(TreeViewLabel(text='SubItem 2'), n1) n2 = tv.add_node(TreeViewLabel(text='Item 2')) tv.add_node(TreeViewLabel(text='SubItem 1'), n2) tv.add_node(TreeViewLabel(text='SubItem 2'), n2) self.add_widget(tv)
def build(self): boxLayout = BoxLayout() tv = TreeView() for i in range(5): node = TreeViewButton() for i2 in range(5): node.add_widget(Label()) tv.add_node(node) # tv.root_options.set #tv.add_node(TreeViewLabel(text='My first item')) #tv.add_node(TreeViewLabel(text='My second item')) boxLayout.add_widget(tv) return boxLayout
def __init__(self, **kwargs): super(GroupScreen, self).__init__(**kwargs) clients = self.consultasector() bridge_view = TreeView() for s in clients: x = str(s[0]) + " - " + str(s[1]) bridge_view.add_node( TreeViewLabel(text=str(x).capitalize(), even_color=[0.5, 0.1, 0.1, 1], odd_color=[0.1, 0.1, 0.5, 1])) self.add_widget(bridge_view)
def define(self, tree1, callback, colors): self.callback = callback self.colors = colors self.tv = TreeView(root_options=dict(text='Playlists'), hide_root=True, on_touch_down=self.touch2, indent_level=10) self.tv.size_hint = 1, None self.tv.bind(minimum_height=self.tv.setter('height')) self.populate_tree_view(self.tv, None, tree1) root = ScrollView(pos=(0, 0)) root.add_widget(self.tv) self.add_widget(root)
def show_treeview_without_root(self): # test with removing a node col = BoxLayout(orientation='vertical') tv = self.populate_treeview(TreeView(hide_root=True)) col.add_widget(tv) btn = Button(text='Remove one node', size_hint_y=None, height=50) def remove_node(*l): if not tv.root.is_leaf: tv.remove_node(tv.root.nodes[0]) btn.bind(on_release=remove_node) col.add_widget(btn) return col
def on_pre_enter(self, *args): controller.setup_stash() # use thread for background task, use clock in a background task to access the ui threading.Thread(target=self.setup_cloud_task).start() file_names = controller.get_uploaded_file_names() self.file_view = TreeView(hide_root=True, indent_level=4) self.file_view.size_hint = 1, None self.file_view.bind(minimum_height=self.file_view.setter('height')) self.scroll_view.add_widget(self.file_view) for file_name in file_names: self.file_view.add_node(TreeViewLabel(text=file_name)) self.max_storage_size = controller.get_max_storage_size() self.usage_bar.max = self.max_storage_size self.update_storage_view()
def build(self): box = BoxLayout() tree = DroppableTreeView() tree.add_node(DraggableNode(text='node1',relation_manager=tree.relation_manager)) tree.add_node(DraggableNode(text='node2',relation_manager=tree.relation_manager)) tree.add_node(DraggableNode(text='node3',relation_manager=tree.relation_manager)) tree.add_node(DraggableNode(text='node4',relation_manager=tree.relation_manager)) box.add_widget(tree) tree2 = TreeView() node = TreeViewLabel(text='node1') tree2.add_node(node) tree2.add_node(TreeViewLabel(text='node2'),node) tree2.add_node(TreeViewLabel(text='node3')) tree2.add_node(TreeViewLabel(text='node4')) box.add_widget(tree2) return box
def build(self): duzen = BoxLayout(orientation='vertical') self.agac_koku = TreeView(hide_root=True) kuruyemisler = [('Sert Kabuklular', ('Ceviz', 'Fındık', 'Badem')), ('Meyve Kuruları', ('Dut', 'Vişne', 'Kayısı', 'İncir')) ] for ky in kuruyemisler: eb = self.agac_koku.add_node(TreeViewLabel(text=ky[0])) for k in ky[1]: self.agac_koku.add_node(TreeViewLabel(text=k), eb) duzen.add_widget(self.agac_koku) return duzen
def __init__(self, **kwargs): super(MainScreen, self).__init__(**kwargs) self.cols = 2 self.tfa = TextInput(multiline=False) self.tfa.bind(text=self.on_text) self.tfa.bind(on_text_validate=self.on_enter) self.add_widget(self.tfa) button = Button(text='Search', font_size=14) button.bind(on_press=self.on_search) self.add_widget(button) self.values = TreeView(root_options={'text': 'Suggestions'}) self.add_widget(self.values) self.lock = Lock() self.suggestions_list = SafeDataModel() self.recent_list = list()
def build(self): agac_koku = TreeView() ebeveyn1 = agac_koku.add_node(TreeViewLabel(text='Ebeveyn 1')) cocuk11 = agac_koku.add_node(TreeViewLabel(text='Çocuk 1 1'), ebeveyn1) cocuk12 = agac_koku.add_node(TreeViewLabel(text='Çocuk 1 2'), ebeveyn1) cocuk121 = agac_koku.add_node(TreeViewLabel(text='Çocuk 1 2 1'), cocuk12) cocuk122 = agac_koku.add_node(TreeViewLabel(text='Çocuk 1 2 2'), cocuk12) ebeveyn2 = agac_koku.add_node(TreeViewLabel(text='Ebeveyn 2')) cocuk21 = agac_koku.add_node(TreeViewLabel(text='Çocuk 2 1'), ebeveyn2) cocuk22 = agac_koku.add_node(TreeViewLabel(text='Çocuk 2 2'), ebeveyn2) return agac_koku
def showAssetSelector(self): """renders the root grounds in the treeview.""" try: popup = Popup(title="select asset") popup.size_hint = (0.8, 0.8) tv = TreeView(root_options=dict(text='Tree One'), hide_root=True, indent_level=4) tv.size_hint = 1, None tv.bind(minimum_height=tv.setter('height')) tv.load_func = self.populateTreeNode tv.bind(selected_node=self.on_assetChanged) root = ScrollView(pos=(0, 0)) root.add_widget(tv) popup.add_widget(root) popup.open() except Exception as e: showError(e)
def build(self): duzen=BoxLayout(orientation='vertical') self.agac_koku = TreeView(hide_root=True, size_hint_y=0.8) kuruyemisler=[('Sert Kabuklular',('Ceviz', 'Fındık', 'Badem')), ('Meyve Kuruları',('Dut', 'Vişne', 'Kayısı', 'İncir'))] for ky in kuruyemisler: eb=self.agac_koku.add_node(TreeViewLabel(text=ky[0])) for k in ky[1]: self.agac_koku.add_node(TreeViewLabel(text=k),eb) duzen.add_widget(self.agac_koku) dgm=Button(text='Elemanları Yaz', size_hint_y=0.2) dgm.bind(on_press=self.elemanlari_yaz) duzen.add_widget(dgm) return duzen