本文整理汇总了Python中tkinter.ttk.Treeview.set_children方法的典型用法代码示例。如果您正苦于以下问题:Python Treeview.set_children方法的具体用法?Python Treeview.set_children怎么用?Python Treeview.set_children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Treeview
的用法示例。
在下文中一共展示了Treeview.set_children方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Gui
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import set_children [as 别名]
#.........这里部分代码省略.........
self.mainWin.grid_rowconfigure(2, weight=1)
self.mainWin.grid_columnconfigure(1, weight=1)
self.probeFetcherScheduler()
self.thProbe.start()
self.resultFetcherScheduler()
self.thResults.start()
self.logger.info("Commander : Starting main window")
self.mainWin.mainloop()
self.logger.debug("Commander : mainloop over")
def recallCommand(self, event):
"""Function to rewrite previous command in box"""
if len(self.commandHistory) != 0:
self.command.set(self.commandHistory[-1])
return "break"
def doCommand(self, event):
"""Executes user command"""
self.commandHistory.append(self.command.get())
self.logger.info("Commander : executing command")
cmd = super().doCommand(self.command.get())
# cmd.join()
self.command.set("")
def updateStatus(self, status):
"""Update status of the probe in status label
:param status: new status"""
self.status.set(status)
self.mainWin.update_idletasks()
def addResult(self, result):
"""Add (prepend) a result in the result test area
:param result: the result to add
"""
self.result.configure(state=NORMAL)
self.result.insert("1.0", result + "\n")
self.result.configure(state=DISABLED)
def setResult(self, result):
"""Put this result in the result area
:param result: result to put
"""
self.result.configure(state=NORMAL)
self.result.set(result)
self.result.configure(state=DISABLED)
def updateProbes(self):
"""Update the list of probes in the Treeview"""
while self.isRunning:
try:
probes = self.probesToItems(self.fetchProbes())
self.probesDisplay.set_children("")
self.updateHeading(0, nProbes=len(probes))
for item in probes:
self.probesDisplay.insert("", "end", values=item)
# self.probesDisplay.set_children('', probes)
except ProbeConnectionFailed:
self.updateStatus("Cannot get list of probes")
self.logger.error("Error while getting list of probes : connection failed", exc_info=1)
finally:
self.doFetchProbes.wait()
def updateHeading(self, index, **kw):
self.probesDisplay.heading(index, anchor=W, text=self.TREE_COLUMNS[index].format(**kw))
@staticmethod
def probesToItems(probes):
"""Transform probe object into lists for display
:param probes: list of probes to transform
"""
return [(str(probe.getId()), probe.getIp(), probe.getStatus()) for probe in probes]
def updateResults(self):
"""Update the results is the box"""
while self.isRunning:
try:
result = self.fetchResults()
self.addResult(result)
except ProbeConnectionFailed:
self.updateStatus("Cannot fetch results")
self.logger.error("Cannot fetch results : connection to probe failed", exc_info=1)
finally:
self.doFetchResults.wait()
def quit(self):
"""Exit and close the commander window"""
self.logger.info("Commander : exiting commander")
self.isRunning = False
self.triggerFetchProbes()
self.thProbe.join()
super().quit()
# no join because answer is blocking...
# self.thResults.join()
self.mainWin.quit()