本文整理匯總了Python中ttk.Treeview.identify方法的典型用法代碼示例。如果您正苦於以下問題:Python Treeview.identify方法的具體用法?Python Treeview.identify怎麽用?Python Treeview.identify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ttk.Treeview
的用法示例。
在下文中一共展示了Treeview.identify方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: pylasticGUI
# 需要導入模塊: from ttk import Treeview [as 別名]
# 或者: from ttk.Treeview import identify [as 別名]
#.........這裏部分代碼省略.........
#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)
def OnDoubleClick(self, event):
item = self.tree.identify('item',event.x,event.y)
if self.tree.item(item,"text") == 'calc':
self.create_window()
def _update_tree(self, event):
# user expanded a node - build the related directory
nodeId = self.tree.focus() # the id of the expanded node
if self.tree.parent(nodeId): # not at root
topChild = self.tree.get_children(nodeId)[0]
# if the node only has a 'dummy' child, remove it and
# build new directory; skip if the node is already
# populated
if self.tree.item(topChild, option='text') == 'dummy':
self.tree.delete(topChild)
path = self.tree.set(nodeId, 'fullpath')
self._populate_tree(nodeId, path, os.listdir(path))
def create_window(self):
t = Toplevel(self)
t.wm_title("Elastic constants")
l = Label(t, text="Elastic constants:")
l.grid(row=0, column=0)
textf = Text(t)
try:
textf.insert(INSERT, self.ec.get_C())
except:
textf.insert(INSERT, '')
textf.grid(row=1, column=0)