本文整理汇总了Python中tkinter.ttk.Treeview.identify_row方法的典型用法代码示例。如果您正苦于以下问题:Python Treeview.identify_row方法的具体用法?Python Treeview.identify_row怎么用?Python Treeview.identify_row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Treeview
的用法示例。
在下文中一共展示了Treeview.identify_row方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DialogOpenArchive
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import identify_row [as 别名]
#.........这里部分代码省略.........
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())
if not urlOrFile.endswith("/"):
# check if it's an absolute URL rather than a path into the archive
if isHttpUrl(urlOrFile):
self.filesource.select(urlOrFile) # absolute path selection
else:
# assume it's a path inside the archive:
self.filesource.select(self.metadataFilePrefix + urlOrFile)
self.accepted = True
self.close()
def close(self, event=None):
self.parent.focus_set()
self.destroy()
def showAltView(self, event=None):
if self.openType == ENTRY_POINTS:
self.loadTreeView(ARCHIVE, _("Select Entry Point"), _("File"))
else:
self.loadTreeView(ENTRY_POINTS, _("Select Archive File"), _("File"))
def leave(self, *args):
self.toolTipRowId = None
def motion(self, *args):
tvRowId = self.treeView.identify_row(args[0].y)
if tvRowId != self.toolTipRowId:
text = None
if self.openType in (ARCHIVE, DISCLOSURE_SYSTEM):
self.toolTipRowId = tvRowId
if tvRowId and len(tvRowId) > 4:
try:
text = self.filenames[ int(tvRowId[4:]) ]
if isinstance(text, tuple):
text = text[1].replace("\\n","\n")
except (KeyError, ValueError):
pass
elif self.openType == ENTRY_POINTS:
try:
epUrl = self.nameToUrls[tvRowId][1]
text = "{0}\n{1}".format(tvRowId, epUrl)
except KeyError:
pass
self.setToolTip(text)
def setToolTip(self, text):
self.toolTip._hide()
if text:
self.toolTipText.set(text)
self.toolTip.configure(state="normal")
self.toolTip._schedule()
else:
self.toolTipText.set("")
self.toolTip.configure(state="disabled")
示例2: DialogOpenArchive
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import identify_row [as 别名]
#.........这里部分代码省略.........
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("/"):
# check if it's an absolute URL rather than a path into the archive
if not isHttpUrl(filename) and self.metadataFilePrefix != self.taxonomyPkgMetaInf:
# assume it's a path inside the archive:
filename = self.metadataFilePrefix + filename
filenames.append(filename)
if filenames:
self.filesource.select(filenames)
self.accepted = True
self.close()
return
elif self.openType in (PLUGIN, PACKAGE):
filename = self.filenames[int(selection[0][4:])][2]
if filename is not None and not filename.endswith("/"):
if hasattr(self, "taxonomyPackage"):
# attempt to unmap the filename to original file
# will be mapped again in loading, but this allows schemaLocation to be unmapped
for prefix, remapping in self.taxonomyPackage["remappings"].items():
if isHttpUrl(remapping):
remapStart = remapping
else:
remapStart = self.metadataFilePrefix + remapping
if filename.startswith(remapStart):
# set unmmapped file
filename = prefix + filename[len(remapStart):]
break
if self.openType in (PLUGIN, PACKAGE):
self.filesource.selection = filename
else:
self.filesource.select(filename)
self.accepted = True
self.close()
def close(self, event=None):
self.parent.focus_set()
self.destroy()
def showAltView(self, event=None):
if self.openType == ENTRY_POINTS:
self.loadTreeView(ARCHIVE, _("Select Entry Point"), _("File"))
else:
self.loadTreeView(ENTRY_POINTS, _("Select Archive File"), _("File"))
def leave(self, *args):
self.toolTipRowId = None
def motion(self, *args):
tvRowId = self.treeView.identify_row(args[0].y)
if tvRowId != self.toolTipRowId:
text = None
if self.openType in (ARCHIVE, DISCLOSURE_SYSTEM, PLUGIN, PACKAGE):
self.toolTipRowId = tvRowId
if tvRowId and len(tvRowId) > 4:
try:
text = self.filenames[ int(tvRowId[4:]) ]
if isinstance(text, tuple):
text = (text[1] or "").replace("\\n","\n")
except (KeyError, ValueError):
pass
elif self.openType == ENTRY_POINTS:
try:
text = "{0}\n{1}".format(tvRowId,
"\n".join(url[1] for url in self.taxonomyPackage["entryPoints"][tvRowId]))
except KeyError:
pass
self.setToolTip(text)
def setToolTip(self, text):
self.toolTip._hide()
if text:
self.toolTipText.set(text)
self.toolTip.configure(state="normal")
self.toolTip._schedule()
else:
self.toolTipText.set("")
self.toolTip.configure(state="disabled")