當前位置: 首頁>>代碼示例>>Python>>正文


Python ttk.Treeview方法代碼示例

本文整理匯總了Python中tkinter.ttk.Treeview方法的典型用法代碼示例。如果您正苦於以下問題:Python ttk.Treeview方法的具體用法?Python ttk.Treeview怎麽用?Python ttk.Treeview使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tkinter.ttk的用法示例。


在下文中一共展示了ttk.Treeview方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: configure_treeview

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.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: __init__

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def __init__(self, master=None, **kw):
        ttk.Treeview.__init__(self, master, **kw)

        self._curfocus = None
        self._inplace_widgets = {}
        self._inplace_widgets_show = {}
        self._inplace_vars = {}
        self._header_clicked = False
        self._header_dragged = False

        # Wheel events?
        self.bind('<<TreeviewSelect>>', self.check_focus)
        self.bind('<4>', lambda e: self.after_idle(self.__updateWnds))
        self.bind('<5>', lambda e: self.after_idle(self.__updateWnds))
        self.bind('<KeyRelease>', self.check_focus)
        self.bind('<Home>', functools.partial(self.__on_key_press, 'Home'))
        self.bind('<End>', functools.partial(self.__on_key_press, 'End'))
        self.bind('<Button-1>', self.__on_button1)
        self.bind('<ButtonRelease-1>', self.__on_button1_release)
        self.bind('<Motion>', self.__on_mouse_motion)
        self.bind('<Configure>', lambda e: self.after_idle(self.__updateWnds)) 
開發者ID:ubuntunux,項目名稱:PyEngine3D,代碼行數:23,代碼來源:EditableTreeview.py

示例3: cget

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def cget(self, key):
        """
        Query widget option.

        :param key: option name
        :type key: str
        :return: value of the option

        To get the list of options for this widget, call the method :meth:`~Table.keys`.
        """
        if key == 'sortable':
            return self._sortable
        elif key == 'drag_cols':
            return self._drag_cols
        elif key == 'drag_rows':
            return self._drag_rows
        else:
            return ttk.Treeview.cget(self, key) 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:20,代碼來源:table.py

示例4: heading

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def heading(self, column, option=None, **kw):
        """
        Query or modify the heading options for the specified column.

        If `kw` is not given, returns a dict of the heading option values. If
        `option` is specified then the value for that option is returned.
        Otherwise, sets the options to the corresponding values.

        :param text: text to display in the column heading
        :type text: str
        :param image: image to display to the right of the column heading
        :type image: PhotoImage
        :param anchor: "n", "ne", "e", "se", "s", "sw", "w", "nw", or "center":
                       alignement of the heading text
        :type anchor: str
        :param command: callback to be invoked when the heading label is pressed.
        :type command: function
        """
        if kw:
            # Set the default image of the heading to the drag icon
            kw.setdefault("image", self._im_drag)
            self._visual_drag.heading(ttk.Treeview.column(self, column, 'id'), option, **kw)
        return ttk.Treeview.heading(self, column, option, **kw) 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:25,代碼來源:table.py

示例5: item

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def item(self, item, option=None, **kw):
        """
        Query or modify the options for the specified item.

        If no options are given, a dict with options/values for the item is returned.
        If option is specified then the value for that option is returned.
        Otherwise, sets the options to the corresponding values as given by `kw`.
        
        :param text: item's label
        :type text: str
        :param image: image to be displayed on the left of the item's label
        :type image: PhotoImage
        :param values: values to put in the columns
        :type values: sequence
        :param open: whether the item's children should be displayed
        :type open: bool
        :param tags: list of tags associated with this item
        :type tags: sequence[str]
        """
        if kw:
            self._visual_drag.item(item, option, **kw)
        return ttk.Treeview.item(self, item, option, **kw) 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:24,代碼來源:table.py

示例6: move

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def move(self, item, parent, index):
        """
        Moves item to position index in parent’s list of children.

        It is illegal to move an item under one of its descendants. If index is
        less than or equal to zero, item is moved to the beginning, if greater
        than or equal to the number of children, it is moved to the end.
        If item was detached it is reattached.

        :param item: item's identifier
        :type item: str
        :param parent: new parent of item
        :type parent: str
        :param index: where in the list of parent’s children to insert item
        :type index: int of "end"
        """
        self._visual_drag.move(item, parent, index)
        ttk.Treeview.move(self, item, parent, index) 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:20,代碼來源:table.py

示例7: set

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def set(self, item, column=None, value=None):
        """
        Query or set the value of given item.

        With one argument, return a dictionary of column/value pairs for the
        specified item. With two arguments, return the current value of the
        specified column. With three arguments, set the value of given column
        in given item to the specified value.

        :param item: item's identifier
        :type item: str
        :param column: column's identifier
        :type column: str, int or None
        :param value: new value
        """
        if value is not None:
            self._visual_drag.set(item, ttk.Treeview.column(self, column, 'id'), value)
        return ttk.Treeview.set(self, item, column, value) 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:20,代碼來源:table.py

示例8: state

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def state(self, statespec=None):
        """
        Modify or inquire widget state.
        
        :param statespec: Widget state is returned if `statespec` is None, 
                          otherwise it is set according to the statespec 
                          flags and then a new state spec is returned 
                          indicating which flags were changed.
        :type statespec: None or sequence[str]
        """
        if statespec:
            if "disabled" in statespec:
                self.bind('<Button-1>', lambda e: 'break')
            elif "!disabled" in statespec:
                self.unbind("<Button-1>")
                self.bind("<Button-1>", self._box_click, True)
            return ttk.Treeview.state(self, statespec)
        else:
            return ttk.Treeview.state(self) 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:21,代碼來源:checkboxtreeview.py

示例9: show_data

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def show_data(data):
    # Setup the root UI
    root = tk.Tk()
    root.title("JSON viewer")
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0, weight=1)

    # Setup the Frames
    tree_frame = ttk.Frame(root, padding="3")
    tree_frame.grid(row=0, column=0, sticky=tk.NSEW)

    # Setup the Tree
    tree = ttk.Treeview(tree_frame, columns='Values')
    tree.tag_configure("d", foreground='blue')
    tree.column('Values', width=100)
    tree.heading('Values', text='Values')
    json_tree(tree, '', data)
    tree.pack(fill=tk.BOTH, expand=1)

    # Limit windows minimum dimensions
    root.update_idletasks()
    root.minsize(500, 500)
    raise_app()

    root.mainloop() 
開發者ID:rene-d,項目名稱:hackerrank,代碼行數:27,代碼來源:hr_menu.py

示例10: __init__

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def __init__(self, app, master):
        super().__init__(master, text="Playlist", padding=4)
        self.app = app
        bf = ttk.Frame(self)
        ttk.Button(bf, text="Move to Top", width=11, command=self.do_to_top).pack()
        ttk.Button(bf, text="Move Up", width=11, command=self.do_move_up).pack()
        ttk.Button(bf, text="Move Down", width=11, command=self.do_move_down).pack()
        ttk.Button(bf, text="Remove", width=11, command=self.do_remove).pack()
        bf.pack(side=tk.LEFT, padx=4)
        sf = ttk.Frame(self)
        cols = [("title", 300), ("artist", 180), ("album", 180), ("length", 80)]
        self.listTree = ttk.Treeview(sf, columns=[col for col, _ in cols], height=10, show="headings")
        vsb = ttk.Scrollbar(orient="vertical", command=self.listTree.yview)
        self.listTree.configure(yscrollcommand=vsb.set)
        self.listTree.grid(column=1, row=0, sticky=tk.NSEW, in_=sf)
        vsb.grid(column=0, row=0, sticky=tk.NS, in_=sf)
        for col, colwidth in cols:
            self.listTree.heading(col, text=col.title())
            self.listTree.column(col, width=colwidth)
        sf.grid_columnconfigure(0, weight=1)
        sf.grid_rowconfigure(0, weight=1)
        sf.pack(side=tk.LEFT, padx=4) 
開發者ID:irmen,項目名稱:synthesizer,代碼行數:24,代碼來源:box.py

示例11: tree_columns

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def tree_columns(self):
        """ Add the columns to the totals tree-view """
        logger.debug("Adding Treeview columns")
        columns = (("session", 40, "#"),
                   ("start", 130, None),
                   ("end", 130, None),
                   ("elapsed", 90, None),
                   ("batch", 50, None),
                   ("iterations", 90, None),
                   ("rate", 60, "EGs/sec"))
        self.tree["columns"] = [column[0] for column in columns]

        for column in columns:
            text = column[2] if column[2] else column[0].title()
            logger.debug("Adding heading: '%s'", text)
            self.tree.heading(column[0], text=text)
            self.tree.column(column[0], width=column[1], anchor=tk.E, minwidth=40)
        self.tree.column("#0", width=40)
        self.tree.heading("#0", text="Graphs")

        return [column[0] for column in columns] 
開發者ID:deepfakes,項目名稱:faceswap,代碼行數:23,代碼來源:display_analysis.py

示例12: create_file_treeview

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.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

示例13: _init_widgets

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def _init_widgets(self):
        # init and place scrollbar
        self.vert_scrollbar = SafeScrollbar(self, orient=tk.VERTICAL)
        self.vert_scrollbar.grid(row=0, column=1, sticky=tk.NSEW)

        # init and place tree
        self.tree = ttk.Treeview(self, yscrollcommand=self.vert_scrollbar.set)
        self.tree.grid(row=0, column=0, sticky=tk.NSEW)
        self.vert_scrollbar["command"] = self.tree.yview

        # set single-cell frame
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        # init tree events
        self.tree.bind("<<TreeviewSelect>>", self._on_select, True)
        self.tree.bind("<Map>", self._update_frame_contents, True)

        # configure the only tree column
        self.tree.column("#0", anchor=tk.W, stretch=True)
        # self.tree.heading('#0', text='Item (type @ line)', anchor=tk.W)
        self.tree["show"] = ("tree",)

        self._class_img = get_workbench().get_image("outline-class")
        self._method_img = get_workbench().get_image("outline-method") 
開發者ID:thonny,項目名稱:thonny,代碼行數:27,代碼來源:outline.py

示例14: __init__

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def __init__(self, path):
        super().__init__()
        self.title("Ttk Treeview")

        columns = ("#1", "#2", "#3")
        self.tree = ttk.Treeview(self, show="headings", columns=columns)
        self.tree.heading("#1", text="Last name")
        self.tree.heading("#2", text="First name")
        self.tree.heading("#3", text="Email")
        ysb = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.tree.yview)
        self.tree.configure(yscroll=ysb.set)

        with open("contacts.csv", newline="") as f:
            for contact in csv.reader(f):
                self.tree.insert("", tk.END, values=contact)
        self.tree.bind("<<TreeviewSelect>>", self.print_selection)

        self.tree.grid(row=0, column=0)
        ysb.grid(row=0, column=1, sticky=tk.N + tk.S)
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Application-Development-Cookbook,代碼行數:23,代碼來源:chapter8_03.py

示例15: __init__

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Treeview [as 別名]
def __init__(self, path):
        super().__init__()
        self.title("Ttk Treeview")

        abspath = os.path.abspath(path)
        self.nodes = {}
        self.tree = ttk.Treeview(self)
        self.tree.heading("#0", text=abspath, anchor=tk.W)
        ysb = ttk.Scrollbar(self, orient=tk.VERTICAL,
                            command=self.tree.yview)
        xsb = ttk.Scrollbar(self, orient=tk.HORIZONTAL,
                            command=self.tree.xview)
        self.tree.configure(yscroll=ysb.set, xscroll=xsb.set)

        self.tree.grid(row=0, column=0, sticky=tk.N + tk.S + tk.E + tk.W)
        ysb.grid(row=0, column=1, sticky=tk.N + tk.S)
        xsb.grid(row=1, column=0, sticky=tk.E + tk.W)
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)

        self.tree.bind("<<TreeviewOpen>>", self.open_node)
        self.populate_node("", abspath) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Application-Development-Cookbook,代碼行數:24,代碼來源:chapter8_04.py


注:本文中的tkinter.ttk.Treeview方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。