Python tkinter.ttk 模块,Treeview() 实例源码

我们从Python开源项目中,提取了以下33个代码示例,用于说明如何使用tkinter.ttk.Treeview()

项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, directory, *args):
        ttk.Frame.__init__(self, parent, *args)
        self.parent = parent
        self._directory = directory

        self.images = {"Directory": tk.PhotoImage(),
                       "File": tk.PhotoImage()}

        self.selected = None

        self._tree = ttk.Treeview(self, show="tree")
        self._tree.pack(fill="both", expand=True)

        self._tree.bind("<<TreeviewSelect>>", self._select, "+")
        # self._tree.bind("<Double-Button-1>", self._open_event)
        self._tree.bind("<<TreeviewOpen>>", self._open_event, "+")
        self._tree.bind("<<TreeviewClose>>", self._close_event, "+")

        self.refresh()
项目:qcri    作者:douville    | 项目源码 | 文件源码
def __init__(self, master, on_selected=None, **kwargs):
        tk.Frame.__init__(self, master, **kwargs)
        self._cache = {}
        self.tree = ttk.Treeview(self)
        self.tree['show'] = 'headings'
        self.tree['columns'] = ('subject', 'tests', 'status', 'bug')
        self.tree.heading('subject', text='Subject')
        self.tree.heading('tests', text='Test')
        self.tree.heading('status', text='Status')
        self.tree.heading('bug', text='Bug')
        self.tree.column('subject', width=60)
        self.tree.column('tests', width=150)
        self.tree.column('status', width=40)
        self.tree.column('bug', width=10)
        self.tree.bind('<<TreeviewSelect>>', on_selected)
        ysb = ttk.Scrollbar(self, orient='vertical', command=self.tree.yview)
        self.tree.grid(row=0, column=0, sticky='nsew')
        ysb.grid(row=0, column=1, sticky='ns')
        self.tree.configure(yscroll=ysb.set)
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, window, *args, **kwargs):
        ttk.Treeview.__init__(self, parent, selectmode="browse", columns=["", ""], *args, **kwargs)
        self.parent = window

        self.heading("#0", text="Resource File")
        self.heading("#1", text="Files")
        self.column("#1", anchor="e", width=50, stretch=False)
        self.heading("#2", text="File Extension")
        self.column("#2", width=100, stretch=False)

        self.widget_menu_tree = tk.Menu(self)
        self.bind("<Button-3>", self.show_menu)

        self.widget_menu_tree.add_command(label="Open", command=self.parent.open_file)
        self.widget_menu_tree.add_command(label="Edit", state="disabled")
        self.widget_menu_tree.add_separator()
        self.widget_menu_tree.add_command(label="Delete", command=self.parent.cmd.tree_delete_selected)
项目:synthesizer    作者:irmen    | 项目源码 | 文件源码
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", 60)]
        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)
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, **kwargs):
        ttk.Frame.__init__(self, parent, **kwargs)
        self.parent = parent
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)

        self.widget_tree = ttk.Treeview(self, selectmode="browse", columns=[""])
        self.widget_tree.grid(row=0, column=0, sticky="nesw")

        self.widget_tree.configure(selectmode="browse")
        self.widget_tree.heading("#0", text="Mod Name")
        self.widget_tree.heading("#1", text="Mod Extension")
        self.widget_tree.column("#1", width=100, stretch=False)

        self.scrollbar_horizontal = ttk.Scrollbar(self, orient="horizontal", command=self.widget_tree.xview)
        self.scrollbar_horizontal.grid(row=1, column=0, sticky="we")

        self.scrollbar_vertical = ttk.Scrollbar(self, orient="vertical", command=self.widget_tree.yview)
        self.scrollbar_vertical.grid(row=0, column=1, sticky="ns")

        self.widget_tree.configure(xscrollcommand=self.scrollbar_horizontal.set,
                                   yscrollcommand=self.scrollbar_vertical.set)
项目:pyfeld    作者:scjurgen    | 项目源码 | 文件源码
def __init__(self, parent):
        Frame.__init__(self, master=parent)
        self.dataCols = ('Z#', 'A', 'zone', 'room', 'info')
        self.dataColSize = (40, 50, 200, 200, 200)
        self.tree = ttk.Treeview(columns=self.dataCols, show='headings')
        self.tree.bind("<Double-1>", self.on_click)
        self.tree.grid(in_=self, row=0, column=0, sticky=NSEW)
        # set frame resize priorities
        self.rowconfigure(0, weight=0)

        for i in range(len(self.dataCols)):
            c = self.dataCols[i]
            self.tree.heading(c, text=c.title(),
                              command=lambda c=c: self._column_sort(c, RaumfeldDesktop.SortDir))
            self.tree.column(c, width=self.dataColSize[i])
        self._load_browse_data()
项目:playground    作者:CastalioPodcast    | 项目源码 | 文件源码
def __init__(self, master):
        tk.Frame.__init__(self, master)
        self.grid(column=0, row=0, sticky=(tk.W, tk.W, tk.E, tk.S))
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)
        self.master.title('Castalio Podcast')

        self.label = ttk.Label(self, text="")
        self.label.grid(column=0, row=0)

        self.tree = ttk.Treeview(self, columns=('date',))
        self.tree.heading('#1', text="Date")
        self.tree.insert('', 0, 'episodes', text='Episodes', open=True)
        self.tree.insert(
            'episodes',
            1,
            text='Episode 82',
            values=('Jan. 8, 2017',)
        )
        self.tree.grid(column=0, row=0, sticky=(tk.W, tk.W, tk.E, tk.S))

        self.pack(fill=tk.X)
项目:PyTasks    作者:TheHirschfield    | 项目源码 | 文件源码
def calenderStyleWidget(self):
        style = ttk.Style(self.master)
        styleArrowLayout = lambda dir: (
            [('Button.focus', {'children': [('Button.%sarrow' % dir, None)]})]
        )
        style.layout('L.TButton', styleArrowLayout('left'))
        style.layout('R.TButton', styleArrowLayout('right'))
        style.configure('Calendar.Treeview', rowheight=40)
项目:PyTasks    作者:TheHirschfield    | 项目源码 | 文件源码
def calenderPlaceWidget(self):
        #Header Frame
        calenderFrame = ttk.Frame(self)
        leftMonthChangeButton = ttk.Button(calenderFrame, style='L.TButton', command=self.setPreviousMonth)
        rightMonthChangeButton = ttk.Button(calenderFrame, style='R.TButton', command=self.setNextMonth)
        self.calenderHeader = ttk.Label(calenderFrame, width=15, anchor='center')
        self.calenderMainView = ttk.Treeview(show='', selectmode='none', height=7, style='Calendar.Treeview')

        #Pack Header
        calenderFrame.pack(in_=self, side='top', pady=4, anchor='center')
        leftMonthChangeButton.grid(in_=calenderFrame)
        self.calenderHeader.grid(in_=calenderFrame, column=1, row=0, padx=12)
        rightMonthChangeButton.grid(in_=calenderFrame, column=2, row=0)
        self.calenderMainView.pack(in_=self, fill='x', side='top')
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, window, **kwargs):
        ttk.Treeview.__init__(self, parent, selectmode="browse", columns=["", "", ""], **kwargs)
        self.parent = window

        self.heading("#0", text="Element")
        self.heading("#1", text="Value")
        self.column("#1", width=250)
        self.heading("#2", text="Type")
        self.column("#2", width=120, stretch=False)

        self.tag_configure("Bold", font=("", "10", "bold"))
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def body(self, master):
        self.tree = ttk.Treeview(master, columns=self.columns)
        self.tree.pack(side="left", fill="both", expand=True)

        for item in self.headings:
            self.tree.heading(item, text=self.headings[item].get("text", ""))
            self.tree.column(item, width=self.headings[item].get("width", 100), stretch=self.headings[item].get("stretch", True))
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Treeview(self.root, **kwargs)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Treeview(self.root, **kwargs)
项目:pyfeld    作者:scjurgen    | 项目源码 | 文件源码
def __init__(self, parent):
        Frame.__init__(self, master=parent)
        self.dir_browser = DirBrowseExtended()

        current_row = 0

        self.pathLabel = ttk.Label(text="0/Path")
        self.pathLabel.grid(in_=self, row=current_row, column=0, sticky=EW)
        self.rowconfigure(current_row, weight=0)
        current_row += 1
        self.search_frame = Frame()

        self.search = ttk.Label(master=self.search_frame, text="Search:")
        self.search.pack(side=LEFT, expand=N, fill=NONE)
        self.search = ttk.Entry(master=self.search_frame, text="?")
        self.search.pack(side=LEFT, expand=Y, fill=X)
        self.search_frame.grid(in_=self, row=current_row, column=0, sticky=EW)
        current_row += 1
        self.rowconfigure(current_row, weight=0)

        # create the tree and scrollbars
        self.dataCols = ('title', 'album', 'artist', 'info')
        self.dataColSize = (200, 200, 200, 100)
        self.tree = ttk.Treeview(columns=self.dataCols, show='headings')
        self.tree.bind("<Double-1>", self.OnDoubleClick)
        self.tree.bind("<Button-3>", self.OnRightClick)

        ysb = ttk.Scrollbar(orient=VERTICAL, command=self.tree.yview)
        xsb = ttk.Scrollbar(orient=HORIZONTAL, command=self.tree.xview)
        self.tree['yscroll'] = ysb.set
        self.tree['xscroll'] = xsb.set

        # add tree and scrollbars to frame
        self.tree.grid(in_=self, row=current_row, column=0, sticky=NSEW)
        ysb.grid(in_=self, row=current_row, column=1, sticky=NS)
        xsb.grid(in_=self, row=current_row+1, column=0, sticky=EW)
        # set frame resize priorities
        self.rowconfigure(current_row, weight=1)
        self.columnconfigure(0, weight=1)
        self._init_tree()
        self._load_browse_data()
项目:ankimaker    作者:carllacan    | 项目源码 | 文件源码
def init_frame(self):
        columns = ['#' + str(c) for c in range(1, 10)]
        self.words_table = ttk.Treeview(self, columns = columns, 
                                        displaycolumns = ['#1'])
        self.words_table.grid(column= 0, row= 0, columnspan= 5)

        # this dictionary will store the index of every field

        self.words_table.heading('#0', text = 'Question',
                                 command = lambda: self.sort_table_by('#0'))
        self.words_table.heading('#1', text = 'Answer',
                                 command = lambda: self.sort_table_by('#1'))

        ttk.Label(self, text='Anki deck name:').grid(column=0, row=1)
        self.name_entry = ttk.Entry(self, width=20)
        self.name_entry.grid(column=1, row=1, columnspan = 1)

        ttk.Label(self, text='File').grid(column=2, row=1)
        self.file_entry = ttk.Entry(self, width=25)
        self.file_entry.grid(column=3, row=1, columnspan = 1)

        self.browse_button = ttk.Button(self, text='Browse',
                                      command=self.select_file)
        self.browse_button.grid(column=4, row=1, columnspan = 1)


        self.create_button = ttk.Button(self, text='Create',
                                      command=self.create_deck)
        self.create_button.grid(column=5, row=1, columnspan = 1)



        # Add padding to everything
        for child in self.winfo_children():
            child.grid_configure(padx=5, pady=5)
项目:DoomTileEditor    作者:jmickle66666666    | 项目源码 | 文件源码
def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.config(width=200)

        self.collections = []

        self.collection_list = Treeview(self, selectmode="browse")
        self.collection_list.heading("#0", text="Texture Collections")
        self.collection_list.bind("<<TreeviewSelect>>", self.on_select)
        self.collection_list.pack(fill=Y, expand=1)
项目:prewarning    作者:croister    | 项目源码 | 文件源码
def update_size(self):
        self.style.configure('Treeview', rowheight=int(self.font_size*1.5))
        self.prewarn['font'] = ('Arial', self.font_size, 'bold')
        self.clock['font'] = ('times', self.font_size, 'bold')
        self.treeview.tag_configure('T', font=('Arial', self.font_size, 'bold'))
        self.scroll_to_last()
项目:Colony    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent):
        self.parent = parent
        self.canvas = self.parent.canvas

        # TODO: Add an easy way for others to make new scenarios without editing code.

        self.scenario_list = []
        self.current_scenarios = 0
        self.selected_scenario = 0

        self.parent.canvas.bind("<Configure>", self.draw_widgets, "+")

        self.canvas.create_text(5, 5, text="Scenarios", anchor="nw", font=colony.get_fonts()["menu"]["title"])

        self.frame_listbox = ttk.Frame(self.parent.canvas)

        self.treeview = ttk.Treeview(self.frame_listbox, show="tree")
        self.treeview.pack(side="left", fill="both", expand=True)
        self.treeview.bind("<<TreeviewSelect>>", self.select_scenario)
        self.treeview.bind("<Double-Button-1>", self.start_game)
        scrollbar_treeview = ttk.Scrollbar(self.frame_listbox, command=self.treeview.yview)
        scrollbar_treeview.pack(side="right", fill="y", expand=True)
        self.treeview.configure(yscrollcommand=scrollbar_treeview.set)

        self.frame_text = ttk.Frame(self.parent.canvas)

        self.text = tk.Text(self.frame_text, wrap="word", width=0, height=12)
        self.text.pack(side="left", fill="both", expand=True)
        scrollbar_text = ttk.Scrollbar(self.frame_text, command=self.text.yview)
        scrollbar_text.pack(side="right", fill="y", expand=False)
        self.text.configure(yscrollcommand=scrollbar_text.set)

        self.game = None

        self.draw_widgets()
        self.default_scenarios()
项目:Zipy    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)
        self.title("Zipy")
        self.geometry("550x500")
        self.minsize(width=350, height=200)
        self.rowconfigure(1, weight=1)
        self.columnconfigure(0, weight=1)

        self.widget_toolbar = Toolbar(self)
        self.widget_toolbar.grid(row=0, column=0, sticky="we")

        self.widget_statusbar = Statusbar(self)
        self.widget_statusbar.grid(row=2, column=0, sticky="we")

        self.frame_treeview = ttk.Frame(self)
        self.frame_treeview.rowconfigure(0, weight=1)
        self.frame_treeview.columnconfigure(0, weight=1)
        self.frame_treeview.grid(row=1, column=0, sticky="nesw")

        self.widget_treeview = Treeview(self.frame_treeview)
        self.widget_treeview.grid(row=0, column=0, sticky="nesw")
        self.widget_treeview["displaycolumns"] = ("File Extension",
                                                  "Date Modified",
                                                  "File Type",
                                                  "Compress Size",
                                                  "File Size",
                                                  "Filler")
        # print(self.widget_treeview["displaycolumns"])

        self.widget_scrollbar_horizontal = ttk.Scrollbar(self.frame_treeview, orient="horizontal",
                                                         command=self.widget_treeview.xview)
        self.widget_scrollbar_horizontal.grid(row=1, column=0, sticky="we")

        self.widget_scrollbar_vertical = ttk.Scrollbar(self.frame_treeview, orient="vertical",
                                                       command=self.widget_treeview.yview)
        self.widget_scrollbar_vertical.grid(row=0, column=1, sticky="ns")

        self.widget_treeview.configure(xscrollcommand=self.widget_scrollbar_horizontal.set,
                                       yscrollcommand=self.widget_scrollbar_vertical.set)

        self.widget_menu = Menu(self)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Treeview(self.root, **kwargs)
项目:WiFi_Password_Viewer    作者:jgrigg2017    | 项目源码 | 文件源码
def multi_column_listbox(self, column_names):
        tree = ttk.Treeview(columns=column_names, show='headings')

        for col in tree['columns']:
            tree.column(col, width=300)
            if col == 'Encryption' or col == 'Authentication':
                tree.column(col, width=100)
            tree.heading(col, text=col, anchor='center',
                         command=lambda x=col: self.sort_column(tree, x, False))
        return tree
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_ttk_treeview(self, columns: list=[], displaycolumns: list or str="#all", height: int=None, padding: list=[], selectmode: str="extended", show: str="tree headings", index: int or str="end", **kwargs):
        """Insert a ttk.Separator into the game."""
        widget = ttk.Treeview(self.text, columns=columns, displaycolumns=displaycolumns, height=height, padding=padding, selectmode=selectmode, show=show, **kwargs)
        self.text.window_create(index, window=widget)

        return widget

    # Bind Functions
项目:warpWarp    作者:ahwmrklas    | 项目源码 | 文件源码
def body(self, master):

        tree = ttk.Treeview(master, columns=['Owner', 'Description'])
        tree.heading('#0', text='Name', anchor=tk.W)
        tree.heading('Owner', text='Owner', anchor=tk.W)
        tree.heading('Description', text='Description', anchor=tk.W)
        tree.column('#0', width=140)
        tree.column('Owner', width=70)
        tree.column('Description', width=220)

        # Store a list of photos. This is just to get around a tk bug.
        # If the photo memory doesn't exist for the duration the photo isn't
        # displayed
        self.photoList = []

        tree.grid(row=0)
        for entry in self.objList:
            if entry:
                print(entry)

                self.photo = tk.PhotoImage(file="resource/images/" + entry['image'])
                self.photo = self.photo.subsample(int(self.photo.width()/20))
                self.photoList.append(self.photo)

                if entry['type'] == 'ship':
                    self.shipInfo(tree, entry)
                elif entry['type'] == 'base':
                    self.baseInfo(tree, entry)
                elif entry['type'] == 'star':
                    self.starInfo(tree, entry)
                else:
                    self.otherInfo(tree, entry)

        return tree # initial focus

    # PURPOSE:
    # RETURNS:
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Treeview(self.root, **kwargs)
项目:Jiffy    作者:h5rdly    | 项目源码 | 文件源码
def scaleup(self, event):
        '''The Treeview widget won't auto-adjust the row height, 
        so requires manual resetting upon font changing'''
        self.font['size']+=1
        self.style.configure('SearchBox.Treeview', rowheight=self.font.metrics('linespace')+1)
项目:Jiffy    作者:h5rdly    | 项目源码 | 文件源码
def scaledown(self, event):
        self.font['size']-=1
        self.style.configure('SearchBox.Treeview', rowheight=self.font.metrics('linespace')+1)
项目:synthesizer    作者:irmen    | 项目源码 | 文件源码
def __init__(self, app, master):
        super().__init__(master, text="Search song", padding=4)
        self.app = app
        self.search_text = tk.StringVar()
        self.filter_choice = tk.StringVar(value="title")
        bf = ttk.Frame(self)
        ttk.Label(bf, text="Search for:").pack()
        e = ttk.Entry(bf, textvariable=self.search_text)
        e.bind("<Return>", self.do_search)
        e.bind("<KeyRelease>", self.on_key_up)
        self.search_job = None
        e.pack()
        ttk.Radiobutton(bf, text="title", value="title", variable=self.filter_choice, width=10).pack()
        ttk.Radiobutton(bf, text="artist", value="artist", variable=self.filter_choice, width=10).pack()
        ttk.Radiobutton(bf, text="album", value="album", variable=self.filter_choice, width=10).pack()
        ttk.Radiobutton(bf, text="year", value="year", variable=self.filter_choice, width=10).pack()
        ttk.Radiobutton(bf, text="genre", value="genre", variable=self.filter_choice, width=10).pack()
        ttk.Button(bf, text="Search", command=self.do_search).pack()
        ttk.Button(bf, text="Add all selected", command=self.do_add_selected).pack()
        bf.pack(side=tk.LEFT)
        sf = ttk.Frame(self)
        cols = [("title", 320), ("artist", 200), ("album", 200), ("year", 50), ("genre", 120), ("length", 60)]
        self.resultTreeView = ttk.Treeview(sf, columns=[col for col, _ in cols], height=11, show="headings")
        vsb = ttk.Scrollbar(orient="vertical", command=self.resultTreeView.yview)
        self.resultTreeView.configure(yscrollcommand=vsb.set)
        self.resultTreeView.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.resultTreeView.heading(col, text=col.title(), command=lambda c=col: self.sortby(self.resultTreeView, c, 0))
            self.resultTreeView.column(col, width=colwidth)
        self.resultTreeView.bind("<Double-1>", self.on_doubleclick)
        sf.grid_columnconfigure(0, weight=1)
        sf.grid_rowconfigure(0, weight=1)
        sf.pack(side=tk.LEFT, padx=4)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self, master, xml=None, heading_text=None, heading_anchor=None, padding=None, cursor=None, takefocus=None, style=None):
        Frame.__init__(self, master, class_="XML_Viwer")

        self._vsb = Scrollbar(self, orient=VERTICAL)
        self._hsb = Scrollbar(self, orient=HORIZONTAL)

        kwargs = {}
        kwargs["yscrollcommand"] = lambda f, l: autoscroll(self._vsb, f, l)
        kwargs["xscrollcommand"] = lambda f, l: autoscroll(self._hsb, f, l)

        if style is not None:
            kwargs["style"] = style

        if padding is not None:
            kwargs["padding"] = padding

        if cursor is not None:
            kwargs["cursor"] = cursor

        if takefocus is not None:
            kwargs["takefocus"] = takefocus

        self._treeview = Treeview(self, **kwargs)

        if heading_text is not None:
            if heading_anchor is not None:
                self._treeview.heading("#0", text=heading_text, anchor=heading_anchor)
            else:
                self._treeview.heading("#0", text=heading_text)

        self._treeview.bind("<<TreeviewOpen>>", self._on_open)
        self._treeview.bind("<<TreeviewClose>>", self._on_close)

        # Without this line, horizontal scrolling doesn't work properly.
        self._treeview.column("#0", stretch= False)

        self._vsb['command'] = self._treeview.yview
        self._hsb['command'] = self._treeview.xview

        self._treeview.grid(column=0, row=0, sticky=N+S+W+E)
        self._vsb.grid(column=1, row=0, sticky=N+S)
        self._hsb.grid(column=0, row=1, sticky=E+W)

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

        self._element_tree = None
        self._item_ID_to_element = {}

        if xml is not None:
            self.parse_xml(xml)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def setUp(self):
        support.root_deiconify()
        self.tv = ttk.Treeview(padding=0)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__()

        self.title("Log")
        self.geometry("600x300")

        self.notebook = ttk.Notebook(self)

        dates_sql = "SELECT DISTINCT date FROM pymodoros ORDER BY date DESC"
        dates = self.master.runQuery(dates_sql, None, True)

        for index, date in enumerate(dates):
            dates[index] = date[0].split()[0]

        dates = sorted(set(dates), reverse=True)

        for date in dates:
            tab = tk.Frame(self.notebook)

            columns = ("name", "finished", "time")

            tree = ttk.Treeview(tab, columns=columns, show="headings")

            tree.heading("name", text="Name")
            tree.heading("finished", text="Full 25 Minutes")
            tree.heading("time", text="Time")

            tree.column("name", anchor="center")
            tree.column("finished", anchor="center")
            tree.column("time", anchor="center")

            tasks_sql = "SELECT * FROM pymodoros WHERE date LIKE ?"
            date_like = date + "%"
            data = (date_like,)

            tasks = self.master.runQuery(tasks_sql, data, True)

            for task_name, task_finished, task_date in tasks:
                task_finished_text = "Yes" if task_finished else "No"
                task_time = task_date.split()[1]
                task_time_pieces = task_time.split(":")
                task_time_pretty = "{}:{}".format(task_time_pieces[0], task_time_pieces[1])
                tree.insert("", tk.END, values=(task_name, task_finished_text, task_time_pretty))


            tree.pack(fill=tk.BOTH, expand=1)
            self.notebook.add(tab, text=date)

        self.notebook.pack(fill=tk.BOTH, expand=1)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__()

        self.title("Log")
        self.geometry("600x300")

        self.notebook = ttk.Notebook(self)
        self.tab_trees = {}

        style = ttk.Style()
        style.configure("Treeview", font=(None,12))
        style.configure("Treeview.Heading", font=(None, 14))

        dates = self.master.get_unique_dates()

        for index, date in enumerate(dates):
            dates[index] = date[0].split()[0]

        dates = sorted(set(dates), reverse=True)

        for date in dates:
            tab = tk.Frame(self.notebook)

            columns = ("name", "finished", "time")

            tree = ttk.Treeview(tab, columns=columns, show="headings")

            tree.heading("name", text="Name")
            tree.heading("finished", text="Full 25 Minutes")
            tree.heading("time", text="Time")

            tree.column("name", anchor="center")
            tree.column("finished", anchor="center")
            tree.column("time", anchor="center")

            tasks = self.master.get_tasks_by_date(date)

            for task_name, task_finished, task_date in tasks:
                task_finished_text = "Yes" if task_finished else "No"
                task_time = task_date.split()[1]
                task_time_pieces = task_time.split(":")
                task_time_pretty = "{}:{}".format(task_time_pieces[0], task_time_pieces[1])
                tree.insert("", tk.END, values=(task_name, task_finished_text, task_time_pretty))

            tree.pack(fill=tk.BOTH, expand=1)
            tree.bind("<Double-Button-1>", self.confirm_delete)
            self.tab_trees[date] = tree

            self.notebook.add(tab, text=date)

        self.notebook.pack(fill=tk.BOTH, expand=1)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__()

        self.title("Log")
        self.geometry("600x300")

        self.notebook = ttk.Notebook(self)

        dates_sql = "SELECT DISTINCT date FROM pymodoros ORDER BY date DESC"
        dates = self.master.runQuery(dates_sql, None, True)

        for index, date in enumerate(dates):
            dates[index] = date[0].split()[0]

        dates = sorted(set(dates), reverse=True)

        for date in dates:
            tab = tk.Frame(self.notebook)

            columns = ("name", "finished", "time")

            tree = ttk.Treeview(tab, columns=columns, show="headings")

            tree.heading("name", text="Name")
            tree.heading("finished", text="Full 25 Minutes")
            tree.heading("time", text="Time")

            tree.column("name", anchor="center")
            tree.column("finished", anchor="center")
            tree.column("time", anchor="center")

            tasks_sql = "SELECT * FROM pymodoros WHERE date LIKE ?"
            date_like = date + "%"
            data = (date_like,)

            tasks = self.master.runQuery(tasks_sql, data, True)

            for task_name, task_finished, task_date in tasks:
                task_finished_text = "Yes" if task_finished else "No"
                task_time = task_date.split()[1]
                task_time_pieces = task_time.split(":")
                task_time_pretty = "{}:{}".format(task_time_pieces[0], task_time_pieces[1])
                tree.insert("", tk.END, values=(task_name, task_finished_text, task_time_pretty))

            tree.pack(fill=tk.BOTH, expand=1)

            self.notebook.add(tab, text=date)

        self.notebook.pack(fill=tk.BOTH, expand=1)
项目:Zipy    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, *args, **kwargs):
        ttk.Treeview.__init__(self, parent, selectmode="browse", columns=["File Extension",
                                                                          "Date Modified",
                                                                          "File Type",
                                                                          "Compress Type",
                                                                          "Comment",
                                                                          "Extra",
                                                                          "Create System",
                                                                          "Create Version",
                                                                          "Extract Version",
                                                                          "Reserved",
                                                                          "Flag Bits",
                                                                          "Volume",
                                                                          "Internal Attr",
                                                                          "External Attr",
                                                                          "Header Offset",
                                                                          "CRC",
                                                                          "Compress Size",
                                                                          "File Size",
                                                                          "Filler"], *args, **kwargs)

        self.heading("#0", text="File Name")
        self.column("#0", width=200, stretch=False)
        self.heading("#1", text="File Extension")
        self.column("#1", width=80, stretch=False)
        self.heading("#2", text="Date Modified")
        self.column("#2", width=100, stretch=False)
        self.heading("#3", text="File Type")
        self.column("#3", width=80, stretch=False)
        self.heading("#4", text="Compress Type")
        self.column("#4", width=100, stretch=False)
        self.heading("#5", text="Comment")
        self.column("#5", width=80, stretch=False)
        self.heading("#6", text="Extra")
        self.column("#6", width=60, stretch=False)
        self.heading("#7", text="Create System")
        self.column("#7", width=100, stretch=False)
        self.heading("#8", text="Create Version")
        self.column("#8", width=100, stretch=False)
        self.heading("#9", text="Extract Version")
        self.column("#9", width=100, stretch=False)
        self.heading("#10", text="Reserved")
        self.column("#10", width=100, stretch=False)
        self.heading("#11", text="Flag Bits")
        self.column("#11", width=100, stretch=False)
        self.heading("#12", text="Volume")
        self.column("#12", width=100, stretch=False)
        self.heading("#13", text="Internal Attr")
        self.column("#13", width=100, stretch=False)
        self.heading("#14", text="External Attr")
        self.column("#14", width=100, stretch=False)
        self.heading("#15", text="Header Offset")
        self.column("#15", width=100, stretch=False)
        self.heading("#16", text="CRC")
        self.column("#16", width=100, stretch=False)
        self.heading("#17", text="Compress Size")
        self.column("#17", width=90, stretch=False)
        self.heading("#18", text="File Size")
        self.column("#18", width=70, stretch=False)
        self.column("#19", width=1)