本文整理汇总了Python中ttk.Treeview类的典型用法代码示例。如果您正苦于以下问题:Python Treeview类的具体用法?Python Treeview怎么用?Python Treeview使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Treeview类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, *args, **kwargs):
# Only a single stack frame can be selected at a time.
kwargs['selectmode'] = 'browse'
Treeview.__init__(self, *args, **kwargs)
self.locals = self.insert(
'', 'end', ':builtins:',
text='builtins',
open=False,
)
self.globals = self.insert(
'', 'end', ':globals:',
text='globals',
open=False,
)
self.locals = self.insert(
'', 'end', ':locals:',
text='locals',
open=True,
)
self['columns'] = ('value',)
self.column('#0', width=150, anchor='w')
self.column('value', width=200, anchor='w')
self.heading('#0', text='Name')
self.heading('value', text='Value')
示例2: selection_set
def selection_set(self, node):
"""Node names on the breakpoint tree are the filename.
On Windows, this requires escaping, because backslashes
in filenames cause problems with Tk.
"""
Treeview.selection_set(self, self._nodify(node))
示例3: __init__
def __init__(self, parent, model):
Treeview.__init__(self, parent, columns=["COL0", "COL1"], selectmode="browse")
self.heading(0, text="Number")
self.heading(1, text="Text")
self["show"] = "headings"
self.counter = 0
self.bind("<<TreeviewSelect>>", self.on_select)
self.model = model
self.model.add_listener(self.on_model)
示例4: __init__
def __init__(self, gesture, master=None, yscrollcommand=None):
self.gesture = gesture
Treeview.__init__(self, master=master, columns=self.generate_columns(), yscrollcommand=yscrollcommand)
self.setup_column_headers()
self.populate_list()
self.pack(fill="both", expand="yes")
示例5: __init__
def __init__(self, parent, timeEntries):
columns = ("project", "start", "stop", "duration")
Treeview.__init__(self, parent, columns=columns)
for col in columns:
self.heading(col, text=col, command=lambda: self.sort_column(col, False))
[self.insertTimeEntry(e) for e in timeEntries.values()]
self.sort_column("start", True)
示例6: initComponents
def initComponents(self):
"""
GUI components initialization
"""
self.buttons = {}
frame1 = Frame(self)
frame1.place(relx=0.01, rely=0.03, width=600, height=30)
self.accountLabel = Label(frame1, text='accStatus')
self.accountLabel.place(x=0, width=80, height=30)
self.buttons['logout'] = Button (frame1, text="Logout")
self.buttons['logout'].place(x=85, height=24, width=80)
self.buttons['about'] = Button (frame1, text="About")
self.buttons['about'].place(x=170, height=24, width=80)
frame2 = Frame(self)
frame2.place(relx=0.01, rely=0.1, width=600, height=30)
self.buttons['new'] = Button (frame2, text="New")
self.buttons['new'].place(x=0, height=24, width=80)
self.buttons['edit'] = Button (frame2, text="Edit")
self.buttons['edit'].place(x=85, height=24, width=80)
self.buttons['delete'] = Button (frame2, text="Delete")
self.buttons['delete'].place(x=170, height=24, width=80)
self.buttons['find'] = Button (frame2, text="Find")
self.buttons['find'].place(x=255, height=24, width=80)
frame3 = Frame(self)
frame3.place(relx=0.01, rely=0.93, width=600, height=30)
self.buttons['prev'] = Button (frame3, text="Prev")
self.buttons['prev'].place(x=0, y=0, height=27, width=67)
self.pageLabel = Label(frame3, text='pageStatus')
self.pageLabel.place(x=85, width=80, height=30)
self.buttons['next'] = Button (frame3, text="Next")
self.buttons['next'].place(x=170, y=0, height=27, width=67)
self.frame = Frame (self)
self.frame.place(relx=0.01, rely=0.16, relheight=0.75, relwidth=0.98)
self.frame.configure(relief=GROOVE)
self.frame.configure(borderwidth="2")
self.frame.configure(relief="groove")
self.frame.grid_columnconfigure(0, weight=1)
self.frame.grid_rowconfigure(0, weight=1)
container = self.frame
tree = Treeview(container, columns=self.tree_columns, show="headings", selectmode='browse')
self.tree = tree
hsb = Scrollbar(container, orient="horizontal", command=self.tree.xview)
self.tree.configure(xscrollcommand=hsb.set)
# self.tree.grid(column=0, row=0, sticky='nsew', in_=container)
self.tree.pack()
hsb.grid(column=0, row=1, sticky='ew')
container.grid_columnconfigure(0, weight=1)
container.grid_rowconfigure(0, weight=1)
tree.grid(column=0, row=0, sticky='nsew')
for col in self.tree_columns:
self.tree.heading(col, text=col.title())
示例7: __init__
def __init__(self, controller):
self.controller = controller
self.currIndex = 0
# initialize the GUI
self.app = Tk()
self.app.title('Jack Magee\'s Pub')
self.tree = Treeview(self.app, height=30)
# name the tree columns, not sure if they have to be named numbers but that's how the example did it
self.tree["columns"]=("one", "two", "three", "four")
# set the column widths
self.tree.column("one", width=200)
self.tree.column("two", width=300)
self.tree.column("three", width=200)
self.tree.column("four", width=200)
# set the column headings
self.tree.heading("#0", text= "ID")
self.tree.heading("one", text="Name")
self.tree.heading("two", text="Order")
self.tree.heading("three", text="Price")
self.tree.heading("four", text="Respond (double-click)")
self.tree.pack()
# register handler for double-clicks
self.tree.bind("<Double-1>", self.OnDoubleClick)
示例8: initUI
def initUI(self):
self.entries_found = []
self.parent.title("Search your command cards")
self.style = Style()
self.style.theme_use("default")
self.pack()
self.input_title = Label(self, text="Enter your command below")
self.input_title.grid(row=0, columnspan=2)
self.input_box = Entry(self, width=90)
self.input_box.grid(row=1, column=0)
self.input_box.focus()
self.input_box.bind("<Key>", self.onUpdateSearch)
self.search_btn = Button(self, text="Search", command=self.onSearch)
self.search_btn.grid(row=1, column=1)
self.output_box = Treeview(self, columns=("Example"))
ysb = Scrollbar(self, orient='vertical', command=self.output_box.yview)
xsb = Scrollbar(self, orient='horizontal', command=self.output_box.xview)
self.output_box.configure(yscroll=ysb.set, xscroll=xsb.set)
self.output_box.heading('Example', text='Example', anchor='w')
self.output_box.column("#0",minwidth=0,width=0, stretch=NO)
self.output_box.column("Example",minwidth=0,width=785)
self.output_box.bind("<Button-1>", self.OnEntryClick)
self.output_box.grid(row=3, columnspan=2)
self.selected_box = Text(self, width=110, height=19)
self.selected_box.grid(row=4, columnspan=2)
self.gotoadd_btn = Button(self, text="Go to Add", command=self.onGoToAdd)
self.gotoadd_btn.grid(row=5)
示例9: _create_treeview
def _create_treeview(self, parent):
f = Frame(parent)
#f.pack(side=TOP, fill=BOTH, expand=Y)
f.grid(row=0, column=0, sticky=NSEW, columnspan=3)
# create the tree and scrollbars
self.dataCols = ('fullpath', 'type', 'status')
self.tree = Treeview(columns=self.dataCols,
displaycolumns='status')
ysb = Scrollbar(orient=VERTICAL, command= self.tree.yview)
xsb = Scrollbar(orient=HORIZONTAL, command= self.tree.xview)
self.tree['yscroll'] = ysb.set
self.tree['xscroll'] = xsb.set
# setup column headings
self.tree.heading('#0', text='Directory Structure', anchor=W)
self.tree.heading('status', text='Status', anchor=W)
self.tree.column('status', stretch=0, width=100)
# add tree and scrollbars to frame
self.tree.grid(in_=f, row=0, column=0, sticky=NSEW)
ysb.grid(in_=f, row=0, column=1, sticky=NS)
xsb.grid(in_=f, row=1, column=0, sticky=EW)
# set frame resizing priorities
f.rowconfigure(0, weight=1)
f.columnconfigure(0, weight=1)
# action to perform when a node is expanded
self.tree.bind('<<TreeviewOpen>>', self._update_tree)
self.tree.bind("<Double-1>", self.OnDoubleClick)
示例10: fill
def fill(self):
super(self.__class__, self).fill()
#Basisvelden
self.identry = EntryField(self.veldenFrame, 'Projectnummer', row=0)
self.naamentry = EntryField(self.veldenFrame, 'Projectnaam', row=1)
self.jaarentry = EntryField(self.veldenFrame, 'Jaar', row=2)
self.budgetentry = EntryField(self.veldenFrame, 'Budget', row=3)
self.keywordLabel = Label(self.veldenFrame, text='Trefwoorden:')
self.keywordLabel.grid(row=4, column=0, sticky=W)
self.keywordText = Text(self.veldenFrame, relief=SUNKEN, wrap=WORD, width=60, height=3)
self.keywordText.grid(row=4, column=1, sticky=W)
#Partners
self.partnersLabel = Label(self.veldenFrame, text='Relaties:')
self.partnersLabel.grid(row=5, column=0)
self.partnersFrame = Frame(self.veldenFrame)
self.partnersFrame.grid(row=5, column=1, sticky=W+E)
self.partnersListBox = Treeview(self.partnersFrame, columns=('Relatie', 'Rol'), height=3, show='headings', selectmode=BROWSE)
self.partnersListBox.grid(row=0, column=0, sticky=W+E)
self.partnersKnopFrame = Frame(self.veldenFrame)
self.partnersKnopFrame.grid(row=6, column=1, sticky=E)
self.pScrollbar = Scrollbar(self.partnersFrame)
self.pScrollbar.grid(row=0, column=1, sticky=N+S+E)
self.partnersListBox.config(yscrollcommand=self.pScrollbar.set)
self.pScrollbar.config(command=self.partnersListBox.yview)
self.partnersToevoegenKnop = Button(self.partnersKnopFrame, text='Toevoegen...', command=self.partnerToevoegen)
self.partnersToevoegenKnop.grid()
self.partnersVerwijderenKnop = Button (self.partnersKnopFrame, text='Verwijderen', command=self.partnerVerwijderen)
self.partnersVerwijderenKnop.grid(row=0, column=1)
self.partnersListBox.bind('<<TreeviewSelect>>', self.nieuwePartnerSelectie)
#Bestanden
self.bestandenHoofdFrame = Frame(self.resultaatframe)
self.bestandenHoofdFrame.grid(row=2)
self.bestandenLabel = Label(self.bestandenHoofdFrame, text='Bestanden:')
self.bestandenLabel.grid(row=7, column=0, sticky=W)
self.bestandenFrame = Frame(self.bestandenHoofdFrame)
self.bestandenFrame.grid(row=7, column=1, sticky=W+E)
self.bestandenListBox = Listbox(self.bestandenFrame, selectmode=EXTENDED, width=50, height=10)
self.bestandenListBox.grid(row=0, column=0, sticky=W+E)
self.bScrollbar = Scrollbar(self.bestandenFrame)
self.bScrollbar.grid(row=0, column=1, sticky=N+S+E)
self.bestandenListBox.config(yscrollcommand=self.bScrollbar.set)
self.bScrollbar.config(command=self.bestandenListBox.yview)
self.bestandenKnopFrame = Frame(self.bestandenHoofdFrame)
self.bestandenKnopFrame.grid(row=8, column=1, sticky=E)
self.bestandenToevoegKnop = Button(self.bestandenKnopFrame, text='Bestanden toevoegen...', command=self.bestandenToevoegen)
self.bestandenToevoegKnop.grid(row=0, column=0, sticky=E)
self.mapToevoegenKnop = Button(self.bestandenKnopFrame, text='Map toevoegen...', command=self.mapToevoegen)
self.mapToevoegenKnop.grid(row=0, column=1, sticky=E)
self.bestandenOphaalKnop = Button(self.bestandenKnopFrame, text='Ophalen...', command=self.bestandenOphalen)
self.bestandenOphaalKnop.grid(row=0, column=2, sticky=E)
self.bestandenVerwijderKnop = Button(self.bestandenKnopFrame, text='Verwijderen', command=self.bestandenVerwijderen)
self.bestandenVerwijderKnop.grid(row=0, column=3, sticky=E)
self.pollBestandenLijst()
self.curid=-1
示例11: createQSOView
def createQSOView(self, master):
self.qsoviewScrollbar = Scrollbar(master)
self.qsoview = Treeview(master, show=('headings'),
yscrollcommand=self.qsoviewScrollbar.set)
self.qsoviewfields = {'day': {'name': "D", 'width': 10},
'month': {'name': "M", 'width': 10},
'year': {'name': "Y", 'width': 20},
'timeon': {'name': "Time", 'width': 30},
'timeoff': {'name': "Timeoff", 'width': 30},
'band': {'name': "Band", 'width': 20},
'freq': {'name': "Frequency", 'width': 50},
'mode': {'name': "Mode", 'width': 25},
'call': {'name': "Call", 'width': 50},
'srst': {'name': "S RST", 'width': 25},
'rrst': {'name': "R RST",'width': 25},
'name': {'name': "Name",'width': 40},
'grid': {'name': "Gridsquare",'width': 30},
'iota': {'name': "IOTA", 'width': 30},
'qsls': {'name': "Q S",'width': 25},
'qsls_date': {'name': "Q S D",'width': 50},
'qslr': {'name': "Q R",'width': 25},
'qslr_date': {'name': "Q R D",'width': 50},
'lotw_qsls': {'name': "LQ S",'width': 25},
'lotw_qsls_date': {'name': "LQ S D",'width': 50},
'lotw_qslr': {'name': "LQ R",'width': 25},
'lotw_qslr_date': {'name': "LQ R D",'width': 50}}
self.qsoviewdisplayesfields = ('day', 'month', 'year', 'timeon',
'band', 'freq', 'mode', 'call',
'srst', 'rrst', 'name', 'grid',
'iota', 'qsls', 'qsls_date', 'qslr',
'qslr_date', 'lotw_qsls', 'lotw_qsls_date', 'lotw_qslr',
'lotw_qslr_date')
self.qsoview["columns"] = self.qsoviewfields.keys()
self.qsoview["displaycolumns"] = self.qsoviewdisplayesfields
self.qsoview.column(0, width=40)
for columnname, data in self.qsoviewfields.items():
# set columnwidth for QSOView
self.qsoview.column(columnname, width=data['width'])
# set QSOView headers
self.qsoview.heading(columnname, text=data['name'])
for i in range(400):
self.qsoview.insert('', 'end', str(i), values=(str(i), 'bar'+str(i)))
self.qsoviewScrollbar.config(command=self.qsoview.yview)
self.qsoviewScrollbar.grid(column=1, row=0, sticky=(N,S))
self.qsoview.grid(column=0, row=0, sticky=(N,S,E,W))
master.columnconfigure(0, weight=1)
master.rowconfigure(0, weight=1)
示例12: __init__
def __init__(self, data, master=None):
Treeview.__init__(self, master=master, columns=["friendly_name", "status"])
self.data = data
self.heading("#0", text="Port", anchor="w")
self.column("#0", width = 150)
self.heading("friendly_name", text="Name", anchor="w")
self.column("friendly_name", width = 250)
self.heading("status", text="Status", anchor="w")
self.column("status", width = 100)
self.bind("<<TreeviewSelect>>", self.update_status_button)
midi.init()
self.populate_list()
self.pack(fill="both", expand="yes")
示例13: left_side
def left_side(self, master):
self.nombre = Entry(master, justify = CENTER, bd = 3, font = ('Ravie', 11), textvariable = self.NameVar)
self.nombre.pack(side = TOP, fill = X)
self.nombre.bind("<Key>", self.Enter)
self.texto = Entry(master, justify = CENTER, bd = 3, font = ('Ravie', 11), textvariable = self.TextVar)
self.texto.pack(side = TOP, fill = X)
self.texto.bind("<Key>", self.Enter)
self.tag = Entry(master, justify = CENTER, bd = 3, font = ('Ravie', 11), textvariable = self.TagsVar)
self.tag.pack(side = TOP, fill = X)
self.tag.bind("<Key>", self.Enter)
self.tree = Treeview(master)
self.tree.pack(side = LEFT, expand = YES, fill = BOTH)
self.tree.bind("<Double-1>", self.OnDoubleClick)
示例14: __init__
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)
示例15: initUI
def initUI(self):
self.columnconfigure(0, weight=0)
self.columnconfigure(1, weight=0)
self.columnconfigure(2, weight=1)
self.columnconfigure(3, weight=1)
self.rowconfigure(0, weight=1)
self.commandFrame = Frame(self, background="white")
self.commandFrame.grid(row=0, column=0, columnspan=5, sticky=W + E)
self.commandFrame.columnconfigure(1, weight=1)
self.btnCommand = Button(self.commandFrame, text="Run")
self.btnCommand.grid(row=0, column=0)
self.strCommand = StringVar()
self.entCommand = Entry(self.commandFrame, textvariable=self.strCommand)
self.entCommand.grid(row=0, column=1, sticky=W + E)
self.lstMacro = Listbox(self)
self.lstMacro.grid(row=1, column=0, sticky=N + S + W + E)
self.treeview = Treeview(self, columns=("Angle"), displaycolumns="#all", selectmode="browse")
self.treeview.grid(row=1, column=1, columnspan=4, sticky=N + S + W + E)
self.treeScrollbar = Scrollbar(self)
self.treeScrollbar.grid(row=1, column=5, sticky=N + S)
self.treeview.config(yscrollcommand=self.treeScrollbar.set)
self.treeScrollbar.config(command=self.treeview.yview)
self.btnFrame = Frame(self, background="white")
self.btnFrame.grid(row=2, column=0, columnspan=5, sticky=W + E)
self.btnRun = Button(self.btnFrame, text="Run", command=self.runMacro)
self.btnRun.grid(row=0, column=0)
self.btnStop = Button(self.btnFrame, text="Stop")
self.btnStop.grid(row=0, column=1)
self.btnSaveMacro = Button(self.btnFrame, text="Save Macro", command=self.saveMacro)
self.btnSaveMacro.grid(row=0, column=2)
self.btnDeleteMacro = Button(self.btnFrame, text="Delete Macro")
self.btnDeleteMacro.grid(row=0, column=3)
self.btnDeleteState = Button(self.btnFrame, text="Delete State")
self.btnDeleteState.grid(row=0, column=4)