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


Python ttk.Treeview方法代码示例

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


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

示例1: configure_treeview

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def configure_treeview(self):
        self.treeview = ttk.Treeview(self)
        self.treeview['columns'] = ["id", "time", 'ms_level', 'precursor_mz', 'precursor_charge', 'activation']
        self.treeview.grid(row=2, column=0, sticky=tk.S + tk.W + tk.E + tk.N)

        self.treeview_scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.treeview.yview)
        self.treeview_scrollbar.grid(row=2, column=0, sticky=tk.S + tk.E + tk.N)
        self.treeview.configure(yscrollcommand=self.treeview_scrollbar.set)

        self.treeview.heading('id', text="Scan ID")
        self.treeview.heading('#0', text='Index')
        self.treeview.heading("time", text='Time (min)')
        self.treeview.heading("ms_level", text='MS Level')
        self.treeview.heading("precursor_mz", text='Precursor M/Z')
        self.treeview.heading("precursor_charge", text='Precursor Z')
        self.treeview.heading("activation", text='Activation')
        self.treeview.column("#0", width=75)
        self.treeview.column("ms_level", width=75)
        self.treeview.column("time", width=75)
        self.treeview.column("precursor_mz", width=100)
        self.treeview.column("precursor_charge", width=100)
        self.treeview.bind("<<TreeviewSelect>>", self.on_row_click) 
开发者ID:mobiusklein,项目名称:ms_deisotope,代码行数:24,代码来源:view.py

示例2: set_treeview_properties

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def set_treeview_properties(self, element):
        """
        Set the information text for the Treeview *element*.
        """
        # set class property
        self.treeview.set(element.treeview_id, "class", element.treeview_class_name)

        # add the check marks for barcodes/variants
        if "variants" in element.labels:
            self.treeview.set(element.treeview_id, "variants", u"\u2713")
        else:
            self.treeview.set(element.treeview_id, "variants", "")
        if "barcodes" in element.labels:
            self.treeview.set(element.treeview_id, "barcodes", u"\u2713")
        else:
            self.treeview.set(element.treeview_id, "barcodes", "")

        self.treeview.set(element.treeview_id, "class", element.treeview_class_name) 
开发者ID:FowlerLab,项目名称:Enrich2,代码行数:20,代码来源:configurator.py

示例3: populate_tree

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def populate_tree(self, element, parent_id=""):
        """
        Recursively populate the Treeview.

        Also populates the *id_cfgstrings*.
        """
        # insert into the Treeview
        element.treeview_id = self.treeview.insert(
            parent_id, "end", text=element.name, open=True
        )
        # add id-element pair to dictionary
        self.element_dict[element.treeview_id] = element
        # set information fields
        self.set_treeview_properties(element)

        # populate for children
        if element.children is not None:
            for child in element.children:
                self.populate_tree(child, parent_id=element.treeview_id) 
开发者ID:FowlerLab,项目名称:Enrich2,代码行数:21,代码来源:configurator.py

示例4: create_file_treeview

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def create_file_treeview(self):
        self.fileTreeView = Treeview(self.main_window)
        self.fileTreeYScrollbar = Scrollbar(self.main_window, orient='vertical', command=self.fileTreeView.yview)
        self.fileTreeXScrollbar = Scrollbar(self.main_window, orient='horizontal', command=self.fileTreeView.xview)
        self.fileTreeView.configure(yscroll=self.fileTreeYScrollbar.set, xscroll=self.fileTreeXScrollbar.set)

        self.fileTreeView.grid(row=self.fileTreeRow, column=self.fileTreeCol, sticky=NS, rowspan=3)
        self.fileTreeYScrollbar.grid(row=self.fileTreeRow, column=self.fileTreeScrollbarCol, sticky=NS, rowspan=3)
        self.fileTreeXScrollbar.grid(row=self.horizontalScrollbarRow, column=self.fileTreeCol, sticky=EW)

        self.fileTreeView.tag_configure('red', background=self.redColor)
        self.fileTreeView.tag_configure('green', background=self.greenColor)
        self.fileTreeView.tag_configure('yellow', background=self.yellowColor)
        self.fileTreeView.tag_configure('purpleLight', background=self.purpleLight)

        # hide it until needed
        self.fileTreeView.grid_remove()
        self.fileTreeYScrollbar.grid_remove()
        self.fileTreeXScrollbar.grid_remove()

    # Text areas 
开发者ID:yebrahim,项目名称:pydiff,代码行数:23,代码来源:mainwindow_ui.py

示例5: _set_up_tree_widget

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def _set_up_tree_widget(self):

        tree_container = ttk.Frame(self.container)

        tree_container.grid(row=0, column=0, sticky=tk.W+tk.E+tk.N+tk.S)

        #tree_container.pack(fill='both', expand=True)

        # create a treeview with dual scrollbars
        self.tree = ttk.Treeview(tree_container, columns=self.headers, show="headings")
        
        vsb = ttk.Scrollbar(tree_container, orient="vertical", command=self.tree.yview)
        hsb = ttk.Scrollbar(tree_container, orient="horizontal", command=self.tree.xview)

        self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)
        self.tree.grid(column=0, row=0, sticky='nsew')

        vsb.grid(column=1, row=0, sticky='ns')
        hsb.grid(column=0, row=1, sticky='ew')

        tree_container.grid_columnconfigure(0, weight=1)
        tree_container.grid_rowconfigure(0, weight=1)

        self.tree.bind("<Double-1>", self.double_click) 
开发者ID:PCWG,项目名称:PCWG,代码行数:26,代码来源:grid_box.py

示例6: setUp

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def setUp(self):
        support.root_deiconify()
        self.tv = ttk.Treeview(padding=0) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:5,代码来源:test_widgets.py

示例7: create

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def create(self, **kwargs):
        return ttk.Treeview(self.root, **kwargs) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:4,代码来源:test_widgets.py

示例8: stackorder

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def stackorder(self, root):
        """return a list of root and toplevel windows in stacking order (topmost is last)"""
        c = root.children
        s = root.tk.eval('wm stackorder {}'.format(root))
        L = [x.lstrip('.') for x in s.split()]
        return [(c[x] if x else root) for x in L]

    ###                                             ###
    # Converstion to/from Dict and Treeview Functions #
    ###                                             ### 
开发者ID:corpnewt,项目名称:ProperTree,代码行数:12,代码来源:plistwindow.py

示例9: remove_row

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def remove_row(self,target=None):
        if target == None or isinstance(target, tk.Event):
            target = "" if not len(self._tree.selection()) else self._tree.selection()[0]
        if target in ("",self.get_root_node()):
            # Can't remove top level
            return
        parent = self._tree.parent(target)
        self.add_undo({
            "type":"remove",
            "cell":target,
            "from":parent,
            "index":self._tree.index(target)
        })
        self._tree.detach(target)
        # self._tree.delete(target) # Removes completely
        # Might include an undo function for removals, at least - tbd
        if not self.edited:
            self.edited = True
            self.title(self.title()+" - Edited")
        # Check if the parent was an array/dict, and update counts
        if parent == "":
            return
        if self.get_check_type(parent).lower() == "array":
            self.update_array_counts(parent)
        self.update_children(parent)
        self.alternate_colors()

    ###                          ###
    # Treeview Data Helper Methods #
    ###                          ### 
开发者ID:corpnewt,项目名称:ProperTree,代码行数:32,代码来源:plistwindow.py

示例10: menu_selectall

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def menu_selectall(self):
        """
        Add all elements in the Treeview to the selection.
        """
        for k in self.element_dict.keys():
            self.treeview.selection_add(k) 
开发者ID:FowlerLab,项目名称:Enrich2,代码行数:8,代码来源:configurator.py

示例11: delete_element

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def delete_element(self, tree_id):
        """
        Delete element with Treeview id *tree_id* from the tree, from the element 
        dictionary, and from the associated data structure. Recursively 
        deletes all children of *tree_id*.

        The tree should be refreshed using :py:meth:`refresh_tree` after 
        each deletion. This is the responsibility of the caller.

        """
        # if self.treeview.exists(tree_id):
        if tree_id in self.element_dict:
            # recursively delete children
            if self.element_dict[tree_id].children is not None:
                for child in self.element_dict[tree_id].children:
                    self.delete_element(child.treeview_id)

            # check if deleting the root element
            if self.root_element.treeview_id == tree_id:
                # clear the root element
                self.root_element = None
            else:
                try:
                    # remove the element from its parent's list of children
                    self.element_dict[tree_id].parent.remove_child_id(tree_id)
                except AttributeError:
                    raise AttributeError("Non-root element lacks proper parent")

            # delete the element from the dictionary
            del self.element_dict[tree_id] 
开发者ID:FowlerLab,项目名称:Enrich2,代码行数:32,代码来源:configurator.py

示例12: refresh_treeview

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def refresh_treeview(self):
        """
        Clears the Treeview and repopulates it with the current contents of the tree.
        """
        # clear the entries in the Treeview
        for x in self.treeview.get_children():
            self.treeview.delete(x)

        # clear the id-element dictionary
        # elements may be given new id's after repopulation
        self.element_dict.clear()

        # repopulate
        if self.root_element is not None:
            self.populate_tree(self.root_element) 
开发者ID:FowlerLab,项目名称:Enrich2,代码行数:17,代码来源:configurator.py

示例13: get_selected_elements

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def get_selected_elements(self):
        """
        Returns a list of elements that are currently selected in the Treeview.

        If no elements are selected, it returns an empty list.
        """
        return [self.get_element(x) for x in self.treeview.selection()] 
开发者ID:FowlerLab,项目名称:Enrich2,代码行数:9,代码来源:configurator.py

示例14: __init__

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Treeview [as 别名]
def __init__(self):
        """create a tkk graphic interface with a main window tk_win"""
        self.__version__ = '0.9.1'
        self._title = "2019-06-16a : 'Support un-named Tabs!'"
        self.conn = None  # Baresql database object
        self.database_file = ""
        self.tk_win = Tk()
        self.tk_win.title('A graphic SQLite Client in 1 Python file')
        self.tk_win.option_add('*tearOff', FALSE)   # hint of tk documentation
        self.tk_win.minsize(600, 200)               # minimal size

        self.font_size = 10
        self.font_wheight = 0
        self.initialdir = "."
        # With a Menubar and Toolbar
        self.create_menu()
        self.create_toolbar()

        # Create style "ButtonNotebook"
        self.create_style()
        # Initiate Drag State
        self.state_drag = False
        self.state_drag_index = 0

        # With a Panedwindow of two frames: 'Database' and 'Queries'
        p = ttk.Panedwindow(self.tk_win, orient=HORIZONTAL)
        p.pack(fill=BOTH, expand=1)

        f_database = ttk.Labelframe(p, text='Databases', width=200, height=100)
        p.add(f_database)
        f_queries = ttk.Labelframe(p, text='Queries', width=200, height=100)
        p.add(f_queries)

        # build tree view 't' inside the left 'Database' Frame
        self.db_tree = ttk.Treeview(f_database, displaycolumns=[],
                                    columns=("detail", "action"))
        self.db_tree.tag_configure("run")
        self.db_tree.pack(fill=BOTH, expand=1)

        # create a  notebook 'n' inside the right 'Queries' Frame
        self.n = NotebookForQueries(self.tk_win, f_queries, [])

        # Bind keyboard shortcuts
        self.tk_win.bind('<F9>', self.run_tab) 
开发者ID:stonebig,项目名称:sqlite_bro,代码行数:46,代码来源:sqlite_bro.py


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