本文整理汇总了Python中API.API.append方法的典型用法代码示例。如果您正苦于以下问题:Python API.append方法的具体用法?Python API.append怎么用?Python API.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API.API
的用法示例。
在下文中一共展示了API.append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GUI
# 需要导入模块: from API import API [as 别名]
# 或者: from API.API import append [as 别名]
#.........这里部分代码省略.........
# Downloads the active selection in the listbox
def downloadFile(self):
# Get the filename from the active listbox item
fileName = self.currentSelectionFileName()
# Call the API read function to get all the data associated with that file
self.api.read(fileName, 0, -1, fileName)
# Get the file name of the active selection in the listbox
def currentSelectionFileName(self):
# Get the index of the active selection
index = self.currentSelectionIndex()
# From the listbox object, pass in the index to get the filename
fileName = self.area.get(index)
return fileName
# Get the index of the active selection in the listbox
def currentSelectionIndex(self):
# Get the index of the active selection
index = self.area.curselection()[0]
return index
# Mark the active selection in the listbox for deletion
def deleteFile(self):
# Get the index of the current active selection
index = self.currentSelectionIndex()
# Get the filename of the current active selection
filename = self.area.get(index)
# Call the API function to mark file for deletion
self.api.delete(filename)
# Change the background color of the selection to denote it has been marked for deletion
self.area.itemconfig(index, {"bg": "salmon"})
# Append the filename to the toDelete list
self.toDelete.append(filename)
# Unmarks the active selection in the listbox for deletion
def undeleteFile(self):
# Get the index of the current active selection
index = self.currentSelectionIndex()
# Get the filename of the current active selection
filename = self.area.get(index)
# See if the file has been marked for deletion
if filename in self.toDelete:
# Call the API function to unmark file for deletion
self.api.undelete(filename)
# Change the background color of the selection to denote it is no longer marked for deletion
self.area.itemconfig(index, {"bg": "white"})
# Remove the filename from the toDelete list
self.toDelete.remove(filename)
# Upload a file from local machine to the distributed file system
def uploadFile(self):
# Get the file name and file path of the file the user wants to upload
fileinfo = self.openFile()
# Create a file with the filename provided
self.api.create(fileinfo[0])
# Append the file data from the file at the given file path
self.api.append(fileinfo[0], fileinfo[1], 1)
# Once that is complete, refresh the file list in the listbox
self.getFiles()
# Prompt the user to select a file
def openFile(self):
# Prompt the user to select a file, and store the returned file path
filepath = tkFileDialog.askopenfilename(**self.file_opt)
# Parse the filepath, and store the last element of the split as the file name