当前位置: 首页>>代码示例>>Python>>正文


Python TreeView.setter方法代码示例

本文整理汇总了Python中kivy.uix.treeview.TreeView.setter方法的典型用法代码示例。如果您正苦于以下问题:Python TreeView.setter方法的具体用法?Python TreeView.setter怎么用?Python TreeView.setter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.uix.treeview.TreeView的用法示例。


在下文中一共展示了TreeView.setter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_content

# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import setter [as 别名]
    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"])
        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:
            text = '%s' % key
            node = TreeViewProperty(text=text, 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)
开发者ID:bob-the-hamster,项目名称:kivy,代码行数:31,代码来源:console.py

示例2: getTreeViewAsFiles

# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import setter [as 别名]
 def getTreeViewAsFiles(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:
             newnode = tv.add_node(TreeViewLabel(text=self.config_files[key].filename, font_size=self.label_font_size, color=self.filename_label_color))
             
             for child_filename in self.config_files[key].child_files:
                 self._addFileNodeToFileTreeView(tv, newnode, self.config_files[key].child_files[child_filename])
                 
             for configkey in self.config_files[key].config:
                 if isinstance(self.config_files[key].config[configkey], dict):
                     self._addDictNodeToFileTreeView(tv, newnode, configkey, self.config_files[key].config[configkey])
                 else:
                     tv.add_node(TreeViewLabel(text=str(configkey) + ':' + str(self.config_files[key].config[configkey]), font_size=self.label_font_size, color=self.key_label_color), newnode)
                             
         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
开发者ID:missionpinball,项目名称:mpf-wizard,代码行数:27,代码来源:mpf_wizard_ui.py

示例3: create_scrollable_treeview

# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import setter [as 别名]
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
开发者ID:ihaque,项目名称:grizzly,代码行数:34,代码来源:kivy_view.py

示例4: build

# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import setter [as 别名]
 def build(self):
     #for i in range(30):
     #    btn = Button(text=str(i), size=(480, 40),
     #                 size_hint=(None, None))
     #    layout.add_widget(btn)
     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'))
     populate_tree_view(tv)
     root = ScrollView(pos = (0, 0))
     root.add_widget(tv)
     return root
开发者ID:MartenButter,项目名称:Miniproject,代码行数:14,代码来源:TreeView.py

示例5: AddAsset

# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import setter [as 别名]
 def AddAsset(self):
     """show the add asset dialog"""
     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_assetSelected)
         root = ScrollView(pos = (0, 0))
         root.add_widget(tv)
         popup.add_widget(root)
         popup.open()
     except Exception as e:
         showError(e)
开发者ID:ATT-JBO,项目名称:ATTBrokerMonitor,代码行数:18,代码来源:main.py

示例6: fill_tree

# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import setter [as 别名]
    def fill_tree(self, filtre):
        self.scroll.clear_widgets()

        tree = TreeView(hide_root=True, size_hint_y=None, size_hint_x = 0.6)
        tree.bind(minimum_height=tree.setter('height'),
                  selected_node=self.show_details)
        self.scroll.add_widget(tree)

        for uv in self.uvs:
            if uv[0].startswith(filtre.upper()) and uv[1] != 0:
                node = TreeViewLabel(text=u"%s   (%s €)" % (uv[0],
                                                                   uv[1]*0.06),
                                            font_size=30, size_hint_y=None,
                                            padding=(20,20))
                tree.add_node(node)

        self.tree = tree
开发者ID:apuyou,项目名称:selfprint,代码行数:19,代码来源:annales.py

示例7: FileCheckUi

# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import setter [as 别名]
class FileCheckUi(App):
    tv = None


    def build(self):
        l = BoxLayout(orientation='vertical')
        b = Button(text='Run')
        b.bind(on_press=self.btn_run)
        b.size_hint = 1, 1
        sv = ScrollView()
        sv.size_hint = 1, 10
        self.tv = TreeView(root_options=dict(text='Results'))
        self.tv.size_hint = 1, None 
        self.tv.bind(minimum_height = self.tv.setter('height')) 
        sv.add_widget(self.tv)
        l.add_widget(b)
        l.add_widget(sv)
        return l

    def list2tree(self, lbl, lst):
        tvn = self.tv.add_node(TreeViewLabel(text=lbl))
        for t in lst:
           self.tv.add_node(TreeViewLabel(text=t), tvn)
 
    def report(self, added, error, missing):
        self.report_clear ()
        self.list2tree ('Added', added)
        self.list2tree('Error', error)
        self.list2tree('Missing', missing)     

    def report_clear(self):
        while len (self.tv.root.nodes) > 0:
                self.tv.remove_node (self.tv.root.nodes[0])
 
    def btn_run(self, value):
        fdb = '/sdcard/Download/filedb.csv'
        self.dw = None
        self.dw = CsvTest.DirWalker ()
        self.dw.filedb.load( fdb)
        self.dw.walk ( '/sdcard/Download')
        self.dw.filedb.save (fdb)
        self.report( self.dw.filedb.added,
            self.dw.filedb.errors, 
            self.dw.filedb.not_visited())
开发者ID:RedFoxPi,项目名称:Playground,代码行数:46,代码来源:FileCheckUi.py

示例8: POSFMApp

# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import setter [as 别名]
class POSFMApp(App):

    def build(self):
	layout = FloatLayout()
        self.tv = TreeView(root_options=dict(text='Tree One'), hide_root=True, indent_level=0, indent_start=0)
        self.tv.size_hint = 1, None
        self.tv.bind(minimum_height = self.tv.setter('height'))
        self.populate_tree_view(self.tv)

	self.camera = Button(text = 'Camera', size_hint =(1/3.,.23),
				background_color=[1,0,0,.6], pos_hint={'x':0,'y':0})
	self.add = Button(text = 'Add', size_hint =(1/3.,.23),
			background_color=[1,0,0,.6], pos_hint={'x':1/3.,'y':0})
	self.sort = Button(text = 'Sort', size_hint =(1/3.,.23), 
			   background_color=[1,0,0,.6], pos_hint={'x':2/3.,'y':0})
        root = ScrollView(pos = (0, 0))
        root.add_widget(self.tv)
	layout.add_widget(root)
	layout.add_widget(self.camera)
	layout.add_widget(self.add)
	layout.add_widget(self.sort)
        return layout

    def populate_tree_view(self, tv):

        for i, item in enumerate(foodlist):
	    if item.categ not in usedcat.keys():
	        catbutton = TreeViewButton(text='%s' % item.categ, font_size = '50sp',
				size = (100, 450), background_color=[1,1,0,1])
	        catbutton.bind(on_press=self.cat_clicked)
                g = self.tv.add_node(catbutton)
		usedcat[item.categ] = g
	    else:
		g = usedcat[item.categ]
	    itembutton = TreeViewButton(text='%s' % item.name, font_size = '30sp',
				size = (100,150), background_color=[0,1,1,1])
	    itembutton.outline_height = 10
	    self.tv.add_node(itembutton, g)

    def cat_clicked(self, button):
        self.tv.toggle_node(button)
开发者ID:fclements22,项目名称:dyloney,代码行数:43,代码来源:main.py

示例9: getMergedTreeView

# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import setter [as 别名]
    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
开发者ID:missionpinball,项目名称:mpf-wizard,代码行数:26,代码来源:mpf_wizard_ui.py

示例10: MainScreen

# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import setter [as 别名]
class MainScreen(Screen):
    file_view = ObjectProperty(None)
    Builder.load_file('gui/mainscreen.kv')
    stop = threading.Event()

    def setup_cloud_task(self):
        try:
            controller.setup_cloud(AES_CRYPTO)
        except CloudTokenError as err:
            open_popup_error('Cloud Token', err)
        self.stop.set()

    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 dismiss_popup(self):
        self._popup.dismiss()

    def select_file(self):
        content = LoadDialog(load=self.upload_file, cancel=self.dismiss_popup)
        self._popup = Popup(title="Upload file", content=content, size_hint=(0.9, 0.9))
        self._popup.open()

    def update_storage_view(self):
        self.used_storage_size = controller.get_used_storage_size()
        self.usage_label.text = controller.get_data_type_format(self.used_storage_size, self.max_storage_size)
        self.usage_bar.value = self.used_storage_size

    def get_free_storage_size(self):
        return self.max_storage_size - self.used_storage_size

    def split_input_file_task(self):
        controller.save_file_input(self.filename, self.file_input, AES_CRYPTO)
        self.file_view.add_node(TreeViewLabel(text=self.filename))
        self.update_storage_view()
        try:
            controller.update_data(self.filename, AES_CRYPTO)
        except CloudTokenError as err:
            open_popup_error('Cloud Token', err)
        self.stop.set()

    def upload_file_task(self):
        with open(os.path.join(self.path, self.filename[0]), utils.READ_BINARY_MODE) as file:
            self.file_input = file.read()

        if controller.is_storage_available(len(self.file_input), self.get_free_storage_size()):
            self.filename = os.path.basename(self.filename[0])
            self.split_input_file_task()
        else:
            open_popup('Upload Error', 'Not enough storage available.')

        self.stop.set()

    def upload_file(self, path, filename):
        self.path = path
        self.filename = filename
        threading.Thread(target=self.upload_file_task).start()
        self.dismiss_popup()

    def get_selected_node(self):
        selected_node = self.file_view.selected_node
        if selected_node is None:
            raise NoSelectedNode('No file has been selected.')
        return selected_node

    def select_location(self):
        try:
            self.selected_node_text = self.get_selected_node().text
        except NoSelectedNode as err:
            open_popup_error('Download error', err)
            return
        content = SaveDialog(save=self.save, cancel=self.dismiss_popup)
        content.file_name_label.text = self.selected_node_text
        self._popup = Popup(title="Download file", content=content,
                            size_hint=(0.9, 0.9))
        self._popup.open()

    def download_file_task(self):
        try:
            controller.download_selected_file(self.selected_node_text, self.path, self.filename, AES_CRYPTO)
            open_popup('Download file', 'Download was successful')
        except (DownloadFileError, FileSizeError, CloudTokenError) as err:
            open_popup_error('Download error', err)
            return
        self.stop.set()

    def save(self, path, filename):
#.........这里部分代码省略.........
开发者ID:marcjulian,项目名称:pyoram,代码行数:103,代码来源:ui.py


注:本文中的kivy.uix.treeview.TreeView.setter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。