本文整理汇总了Python中tkinter.ttk.Treeview.move方法的典型用法代码示例。如果您正苦于以下问题:Python Treeview.move方法的具体用法?Python Treeview.move怎么用?Python Treeview.move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Treeview
的用法示例。
在下文中一共展示了Treeview.move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BioInfo
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import move [as 别名]
#.........这里部分代码省略.........
# (List B and No List) or (No List and List B)
elif ((self.list1 is not None and self.typeList1 == ListBioType.TypeB) and (self.list2 is None)) or\
((self.list2 is not None and self.typeList2 == ListBioType.TypeB) and (self.list1 is None)):
self.resetTree()
try:
listComp = ListComparator(self.list1, self.list2, self.entryPVal.get(), self.entryFoldC.get())
for e in listComp.getFilterListB():
self.tree.insert('', 'end', values=e)
except IndexError:
showerror("Erreur : liste A invalide", "Le fichier liste A n'est pas un fichier valide")
# (List A and List B) or (List B and List A)
elif ((self.list1 is not None and self.typeList1 == ListBioType.TypeA) and \
(self.list2 is not None and self.typeList2 == ListBioType.TypeB)) or \
((self.list1 is not None and self.typeList1 == ListBioType.TypeB) and \
(self.list2 is not None and self.typeList2 == ListBioType.TypeA)):
self.resetTree()
listA = ""
listB = ""
if self.typeList1 == ListBioType.TypeA:
listA = self.list1
else:
listA = self.list2
if self.typeList1 == ListBioType.TypeB:
listB = self.list1
else:
listB = self.list2
try:
listComp = ListComparator(listA, listB, self.entryPVal.get(), self.entryFoldC.get(), self.entryNote.get())
for e in listComp.getDiffAandB():
self.tree.insert('', 'end', values=e)
except IndexError:
showerror("Erreur : liste A ou B invalide", "Le fichier liste A ou B n'est pas un fichier valide")
# (List A and List A)
elif ((self.list1 is not None and self.typeList1 == ListBioType.TypeA) and \
(self.list2 is not None and self.typeList2 == ListBioType.TypeA)):
self.resetTree()
try:
listComp = ListComparator(self.list1, self.list2, self.entryPVal.get(), self.entryFoldC.get(), self.entryNote.get())
for e in listComp.getDiffAandA():
self.tree.insert('', 'end', values=e)
except IndexError:
showerror("Erreur : liste A ou B invalide", "Le fichier liste A ou B n'est pas un fichier valide")
# (List B and List B)
elif ((self.list1 is not None and self.typeList1 == ListBioType.TypeB) and \
(self.list2 is not None and self.typeList2 == ListBioType.TypeB)):
self.resetTree()
try:
listComp = ListComparator(self.list1, self.list2, self.entryPVal.get(), self.entryFoldC.get())
for e in listComp.getDiffBandB():
self.tree.insert('', 'end', values=e)
except IndexError:
showerror("Erreur : liste A ou B invalide", "Le fichier liste A ou B n'est pas un fichier valide")
else:
showerror("Erreur : Combinaisons de listes invalides", "Votre choix de types de listes ne correspond à aucune combinaison possible, contacter le developpeur")
def export(self):
if len(self.tree.get_children()) == 0:
showinfo("Export", "Il n'y a rien à exporter")
return
fname = asksaveasfilename(filetypes=(("CSV files", "*.csv"),
("All files", "*.*") ))
if fname:
resExp = []
for it in self.tree.get_children():
resExp.append(self.tree.item(it)["values"])
expTabToCSV = TreeExportator(resExp, fname)
expTabToCSV.export()
showinfo("Export", "Exportation au format CSV réussi")
def columnSort (self, col, descending=False):
data = [(self.tree.set(child, col), child) for child in self.tree.get_children('')]
data.sort(reverse=descending)
for indx, item in enumerate(data):
self.tree.move(item[1], '', indx)
# reverse sort direction for next sort operation
self.SortDir = not descending
示例2: ElementListWidget
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import move [as 别名]
class ElementListWidget(Frame):
def __init__(self, parent, label, columns, showError):
Frame.__init__(self, parent)
self.showError = showError
self.columnconfigure(0, weight = 1)
self.rowconfigure(1, weight = 1)
# Название таблицы
self.titleLabel = Label(self, text = label)
self.titleLabel.grid(column = 0, row = 0, sticky = W + E)
# Таблица значений
columns = ("Метка", "№") + columns
self.tree = Treeview(self, columns = columns, displaycolumns = columns,
selectmode = "browse")
self.tree.grid(column = 0, row = 1, sticky = W + N + E + S)
# Настраиваем внешний вид таблицы (первые колонки)
self.tree.column("#0", width = 0, stretch = 0) # Прячем колонку с иконкой
self.tree.column( columns[0], anchor = W, width = 150)
self.tree.heading(columns[0], anchor = W, text = columns[0])
self.tree.column( columns[1], anchor = E, width = 80)
self.tree.heading(columns[1], anchor = E, text = columns[1])
self.tree.bind("<<TreeviewSelect>>", self.onSelectionChanged)
# Панель с кнопками
self.buttonPanel = Frame(self)
self.buttonPanel.grid(column = 0, row = 2, sticky = W + E)
self.buttonPanel.columnconfigure(0, weight = 1)
self.buttonPanel.columnconfigure(3, minsize = emptySpaceSize, weight = 0)
self.buttonPanel.columnconfigure(6, minsize = emptySpaceSize, weight = 0)
self.buttonPanel.columnconfigure(9, weight = 1)
# Кнопки добавления/удаления элемента
self.buttonAdd = Button(self.buttonPanel, text = "+", width = 3,
command = self.onButtonAddClicked)
self.buttonAdd.grid(column = 1, row = 0)
self.buttonRemove = Button(self.buttonPanel, text = "-", width = 3, state = DISABLED,
command = self.onButtonRemoveClicked)
self.buttonRemove.grid(column = 2, row = 0)
# Кнопки перемещения элемента
self.buttonUp = Button(self.buttonPanel, text = "↑", width = 3, state = DISABLED,
command = self.onButtonUpClicked)
self.buttonUp.grid(column = 4, row = 0)
self.buttonDown = Button(self.buttonPanel, text = "↓", width = 3, state = DISABLED,
command = self.onButtonDownClicked)
self.buttonDown.grid(column = 5, row = 0)
# Кнопки применить/отменить (для выбранного элемента)
self.buttonCancel = Button(self.buttonPanel, text = "✗", width = 3,
command = self.updateSelectedFrame)
self.buttonCancel.grid(column = 7, row = 0)
self.buttonApply = Button(self.buttonPanel, text = "✓", width = 3,
command = self.onButtonApplyClicked)
self.buttonApply.grid(column = 8, row = 0)
# Редактирование выделенного элемента
self.i = StringVar()
self.label = (StringVar(), StringVar())
self.selectedFrame = Frame(self)
self.selectedFrame.grid(column = 0, row = 3, sticky = W + E)
# Номер
Label(self.selectedFrame, text = "№:") \
.grid(column = 0, row = 0)
Label(self.selectedFrame, textvariable = self.i, width = 3, justify = RIGHT) \
.grid(column = 1, row = 0)
# Пустое пространство
self.selectedFrame.columnconfigure(2, minsize = emptySpaceSize, weight = 0)
# Метка
Entry(self.selectedFrame, textvariable = self.label[0]) \
.grid(column = 3, row = 0, sticky = W + E)
Entry(self.selectedFrame, textvariable = self.label[1], bg = defaultValueBG) \
.grid(column = 4, row = 0, sticky = W + E)
# Виджет для элементов классов-потомков
self.detailFrame = Frame(self.selectedFrame)
self.detailFrame.grid(column = 3, row = 1, columnspan = 2, sticky = W + N + E + S)
self.selectedFrame.columnconfigure(3, weight = 1)
self.selectedFrame.columnconfigure(4, weight = 1)
self.selectedFrame.rowconfigure(1, weight = 1)
#.........这里部分代码省略.........