本文整理汇总了Python中tkinter.ttk.Treeview.see方法的典型用法代码示例。如果您正苦于以下问题:Python Treeview.see方法的具体用法?Python Treeview.see怎么用?Python Treeview.see使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Treeview
的用法示例。
在下文中一共展示了Treeview.see方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DialogOpenArchive
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import see [as 别名]
#.........这里部分代码省略.........
self.treeView.set(node, "name", name)
self.treeView.set(node, "vers", vers)
self.treeView.set(node, "descr", descr)
self.treeView.set(node, "license", license)
elif openType == PACKAGE:
self.treeView.set(node, "vers", vers)
self.treeView.set(node, "descr", descr)
self.treeView.set(node, "license", license)
if self.selection == filename:
selectedNode = node
loadedPaths.append(path)
elif openType == ENTRY_POINTS:
self.treeView.column("#0", width=200, anchor="w")
self.treeView.heading("#0", text="Name")
self.treeView["columns"] = ("url",)
self.treeView.column("url", width=300, anchor="w")
self.treeView.heading("url", text="URL")
for fileType, fileUrl in getattr(self, "packageContainedInstances", ()):
self.treeView.insert("", "end", fileUrl,
values=fileType,
text=fileUrl or urls[0][2])
for name, urls in sorted(self.taxonomyPackage["entryPoints"].items(), key=lambda i:i[0][2]):
self.treeView.insert("", "end", name,
values="\n".join(url[1] for url in urls),
text=name or urls[0][2])
self.hasToolTip = True
else: # unknown openType
return None
if selectedNode:
self.treeView.see(selectedNode)
self.treeView.selection_set(selectedNode)
if self.showAltViewButton:
self.altViewButton.config(text=_("Show Files") if openType == ENTRY_POINTS else _("Show Entries"))
def ok(self, event=None):
selection = self.treeView.selection()
if len(selection) > 0:
if hasattr(self, "taxonomyPackage"):
# load file source remappings
self.filesource.mappedPaths = self.taxonomyPackage["remappings"]
filename = None
if self.openType in (ARCHIVE, DISCLOSURE_SYSTEM):
filename = self.filenames[int(selection[0][4:])]
if isinstance(filename,tuple):
if self.isRss:
filename = filename[4]
else:
filename = filename[0]
elif self.openType == ENTRY_POINTS:
epName = selection[0]
#index 0 is the remapped Url, as opposed to the canonical one used for display
# Greg Acsone reports [0] does not work for Corep 1.6 pkgs, need [1], old style packages
filenames = []
for _url, _type in self.packageContainedInstances: # check if selection was an inline instance
if _type == epName:
filenames.append(_url)
if not filenames: # else if it's a named taxonomy entry point
for url in self.taxonomyPackage["entryPoints"][epName]:
filename = url[0]
if not filename.endswith("/"):
示例2: DialogOpenArchive
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import see [as 别名]
#.........这里部分代码省略.........
self.hasToolTip = True
if filename.endswith("/"):
filename = filename[:-1]
path = filename.split("/")
if not self.isRss and len(path) > 1 and path[:-1] in loadedPaths:
parent = "file{0}".format(loadedPaths.index(path[:-1]))
else:
parent = ""
node = self.treeView.insert(parent, "end", "file{0}".format(i), text=path[-1])
if self.isRss:
self.treeView.set(node, "descr", form)
self.treeView.set(node, "date", date)
self.treeView.set(node, "instDoc", os.path.basename(instDoc))
if self.selection == filename:
selectedNode = node
loadedPaths.append(path)
elif openType == ENTRY_POINTS:
self.treeView.column("#0", width=150, anchor="w")
self.treeView.heading("#0", text="Name")
self.treeView["columns"] = ("url",)
self.treeView.column("url", width=350, anchor="w")
self.treeView.heading("url", text="URL")
for name, urls in self.nameToUrls.items():
displayUrl = urls[1] # display the canonical URL
self.treeView.insert("", "end", name, values=[displayUrl], text=name)
self.hasToolTip = True
else: # unknown openType
return None
if selectedNode:
self.treeView.see(selectedNode)
self.treeView.selection_set(selectedNode)
if self.showAltViewButton:
self.altViewButton.config(text=_("Show Files") if openType == ENTRY_POINTS else _("Show Entries"))
def ok(self, event=None):
selection = self.treeView.selection()
if len(selection) > 0:
if self.openType in (ARCHIVE, DISCLOSURE_SYSTEM):
filename = self.filenames[int(selection[0][4:])]
if isinstance(filename,tuple):
if self.isRss:
filename = filename[4]
else:
filename = filename[0]
if not filename.endswith("/"):
self.filesource.select(filename)
self.accepted = True
self.close()
elif self.openType == ENTRY_POINTS:
epName = selection[0]
#index 0 is the remapped Url, as opposed to the canonical one used for display
urlOrFile = self.nameToUrls[epName][0]
# load file source remappings
self.filesource.mappedPaths = \
dict((prefix,
remapping if isHttpUrl(remapping)
else (self.filesource.baseurl + os.sep + self.metadataFilePrefix +remapping.replace("/", os.sep)))
for prefix, remapping in self.remappings.items())
示例3: NameView
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import see [as 别名]
class NameView(object):
"""Shows a treeview of unique names."""
def __init__(self, master, names):
self.widget = Frame(master)
self._tree = Treeview(self.widget, columns='name')
self._tree.grid(row=0,column=0, sticky=(N,S,W,E))
self._tree.view = self
self.widget.columnconfigure(0, weight=1)
self.widget.rowconfigure(0,weight=1)
self._tree.column('name', width=50)
self._tree['show'] = 'tree'
actions = {'edit': lambda e: self.edit(),
'search': lambda e: self.search(),
'focus_next': lambda e: self.focus_next(),
'focus_prev': lambda e: self.focus_prev(),
'select': lambda e: self._tree.selection_toggle(self._tree.focus()),
'clear_selection': lambda e: self._tree.selection_set([])
}
kb.make_bindings(kb.tagview, actions, self._tree.bind)
self._iids = dict()
self._names = dict()
logger.debug('Names: %s', names)
self.widget.focus_set = self._tree.focus_set
for name in sorted(names):
iid = self._tree.insert('', 'end', text=name)
self._names[iid] = name
self._iids[name] = iid
self._scroll = Scrollbar(self.widget, command=self._tree.yview)
self._tree['yscrollcommand'] = self._scroll.set
self._scroll.grid(row=0, column=1, sticky=(N, S))
self.widget.columnconfigure(1, weight=0)
def selection(self):
logger.debug('Selection: %s', self._tree.selection())
return [self._names[iid] for iid in self._tree.selection()]
def edit(self):
self._tree.event_generate('<<NameViewEdit>>')
def search(self):
if len(self._tree.selection()) == 0:
self._tree.selection_add(self._tree.focus())
self._tree.event_generate('<<NameViewSearch>>')
def append(self, names):
logger.debug('Append names: %s', names)
for name in names:
if name not in self._names.values():
iid = self._tree.insert('', 'end', text=name)
self._names[iid] = name
self._iids[name] = iid
def delete(self, name):
self._tree.delete(self._iids[name])
del self._names[self._iids[name]]
del self._iids[name]
def _focus(self, iid):
self._tree.focus(iid)
self._tree.see(iid)
def focus_next(self):
cur_iid = self._tree.focus()
next_iid = self._tree.next(cur_iid)
if next_iid == '':
iids = self._tree.get_children()
next_iid = iids[0]
self._focus(next_iid)
def focus_prev(self):
cur_iid = self._tree.focus()
prev_iid = self._tree.prev(cur_iid)
if prev_iid == '':
iids = self._tree.get_children()
prev_iid = iids[-1]
self._focus(prev_iid)
def jump_to(self, name):
try:
iid = self._iids[name]
self._focus(iid)
except KeyError:
pass
def get_names(self):
return tuple(self._names.values())
def set(self, names):
self._tree.delete(*self._iids.values())
self._iids.clear()
self._names.clear()
for name in sorted(names):
iid = self._tree.insert('', 'end', text=name)
self._names[iid] = name
self._iids[name] = iid