本文整理汇总了Python中tkFileDialog.askopenfilenames函数的典型用法代码示例。如果您正苦于以下问题:Python askopenfilenames函数的具体用法?Python askopenfilenames怎么用?Python askopenfilenames使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了askopenfilenames函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_track
def add_track(self):
"""
Opens a dialog box to open files,
then stores the tracks in the playlist.
"""
# get the filez
if self.options.initial_track_dir=='':
filez = tkFileDialog.askopenfilenames(parent=self.root,title='Choose the file(s)')
else:
filez = tkFileDialog.askopenfilenames(initialdir=self.options.initial_track_dir,parent=self.root,title='Choose the file(s)')
filez = self.root.tk.splitlist(filez)
for file in filez:
self.file = file
if self.file=="":
return
self.options.initial_track_dir = ''
# split it to use leaf as the initial title
self.file_pieces = self.file.split("/")
# append it to the playlist
self.playlist.append([self.file, self.file_pieces[-1],'',''])
# add title to playlist display
self.track_titles_display.insert(END, self.file_pieces[-1])
# and set the selected track
if len(filez)>1:
index = self.playlist.length() - len(filez)
else:
index = self.playlist.length() - 1
self.playlist.select(index)
self.display_selected_track(self.playlist.selected_track_index())
示例2: vyberSouboruu
def vyberSouboruu():
#print u"tak jsem uvnitø funkce a právì tisknu tuto vìtu :-)"
import tkFileDialog
nazev=tkFileDialog.askopenfilenames(filetypes=(('image files', '*.jpg *.png *.gif'), ('all files', '*.*')))
#print nazev
vstup.delete(0, END)
vstup.insert(0, nazev)
示例3: loadFromJSON
def loadFromJSON(self):
flist = tkFileDialog.askopenfilenames(title="Open captions file...",
filetypes = [("JSON file", "*.json"),
("All files", "*")],
initialfile = "captions.json",
multiple = False)
if flist:
name = compatibleFileDialogResult(flist)[0]
try:
f = open(name)
str = f.read()
f.close()
try:
cap = fromJSON(str)
except ValueError:
showerror(title = "Error:",
message = "file: "+name+" is malformed!")
if type(cap) == type({}):
self.album.captions = cap
caption = self.album.getCaption(self.selection)
self.textedit.delete("1.0", END)
self.textedit.insert(END, caption)
else:
showerror(title = "Error:",
message = "file "+name+" does not contain a\n"+
"captions dictionary")
except IOError:
showerror(title = "Error:",
message = "could not read file: "+name)
示例4: _add_mdout
def _add_mdout(self):
""" Get open filenames """
fnames = askopenfilenames(title='Select Mdout File(s)', parent=self,
filetypes=[('Mdout Files', '*.mdout'),
('All Files', '*')])
for f in fnames:
self.mdout += AmberMdout(f)
示例5: SelectBDFs
def SelectBDFs():
FilesSelected = tkFileDialog.askopenfilenames(title = "Select File(s)", filetypes=[("allfiles","*")] )
FilesSelected = Fix_askopenfilenames1( FilesSelected )
#print "--SelectFilesForCSV(in DEF)[after fix]:"
#for i in FilesSelected:
# print i
BDFin.set( FilesSelected )
示例6: read_matfile
def read_matfile(infiles=None):
"""function to read in andrew's matlab files"""
master=Tk()
master.withdraw()
if infiles==None:
infiles=tkFileDialog.askopenfilenames(title='Choose one or more matlab TOD file',initialdir='c:/ANC/data/matlab_data/')
infiles=master.tk.splitlist(infiles)
data_arrays=np.zeros(0)
datad={}
vlowarray=[]
vhiarray=[]
gainarray=[]
for filename in infiles:
#print filename
mat=scipy.io.loadmat(filename)
toi=-mat['out']['V1'][0][0][0]/(mat['out']['Vb'][0][0][0][0]-mat['out']['Va'][0][0][0][0])
gainarray.append(1.)
vlowarray.append(mat['out']['Va'][0][0][0][0])
vhiarray.append(mat['out']['Vb'][0][0][0][0])
samplerate=np.int(1/(mat['out']['t'][0][0][0][1]-mat['out']['t'][0][0][0][0]))
data_arrays=np.concatenate((data_arrays,toi),axis=0)
datad['data']=data_arrays
datad['samplerate']=samplerate
datad['gain']=np.array(gainarray)
datad['v_low']=np.array(vlowarray)
datad['v_hi']=np.array(vhiarray)
return datad
示例7: browse
def browse():
global filez
filez = tkFileDialog.askopenfilenames(parent=root,title='Choose a file')
entry = ''
for fil in filez:
entry =entry+fil+", "
fileEntry.set(entry)
示例8: getData
def getData(self):
"""Read the data from txt files"""
try:
import matplotlib.pyplot as plt
self.names = tkFileDialog.askopenfilenames(title='Choose acceleration files')
self.num = 0
for name in self.names:
if(self.option == 0):
self.data = genfromtxt(name, delimiter=';')
else:
self.data = genfromtxt(name, delimiter=',')
self.lista.append(self.data)
self.num = self.num + 1
#Offset of each sample
self.offsets = zeros((1,self.num));
self.limit_l = 0
self.limit_r = 100
self.off = tk.Scale(self.master, from_=-1000, to=1000, orient=tk.HORIZONTAL, resolution=1, length=600, command = self.setOffset, label = 'Offset')
self.off.grid(row=7,column=0, columnspan = 5)
self.ri = tk.Scale(self.master, from_=-800, to=800, orient=tk.HORIZONTAL, resolution=1, length=600, command = self.setLimit_r, label = 'Right limit')
self.ri.set(self.limit_r)
self.ri.grid(row=8,column=0, columnspan = 5)
self.le = tk.Scale(self.master, from_=-1000, to=1000, orient=tk.HORIZONTAL, resolution=1, length=600, command = self.setLimit_l, label = 'Left limt')
self.le.set(self.limit_l)
self.le.grid(row=9,column=0, columnspan = 5)
self.plotData("all")
self.new_lista = self.lista
except:
showerror("Error in the files")
示例9: loadParty
def loadParty(self):
load_files = tkFileDialog.askopenfilenames(title='Choose which party members to add', initialdir='save_files/',filetypes=[('', '*.ddchar')])
for load_file in load_files:
name = load_file
print name
return
示例10: open_files
def open_files(self):
filetypes = [('All files', '.*'), ('Comic files', ('*.cbr', '*.cbz', '*.zip', '*.rar', '*.pdf'))]
f = tkFileDialog.askopenfilenames(title="Choose files", filetypes=filetypes)
if not isinstance(f, tuple):
f = self.master.tk.splitlist(f)
self.filelist.extend(f)
self.refresh_list()
示例11: chooseFile
def chooseFile(self):
filez = tkFileDialog.askopenfilenames()
splitFilez = self.tk.splitlist(filez)
tex.insert(tk.END,'============================================================================\n')
tex.insert(tk.END,'Adding File\n')
tex.see(tk.END)
tex.update_idletasks()
for item in splitFilez :
print "ADD %s" %item
tex.insert(tk.END,'{} Added\n'.format(item))
tex.see(tk.END)
tex.update_idletasks()
openIt = open(item,'r')
allFile.append(item) #each file
## self.checkEnd(item)
## file_contents = openIt.read()
## print file_contents
## loadT.append(file_contents)
## openIt.close()
## a = ''.join(loadT)
## b = a.rstrip()
## for word in word_tokenize(b):
## try:
## loadTr.append(word)
tex.insert(tk.END,'Adding Completed \n')
tex.insert(tk.END,'============================================================================\n')
tex.see(tk.END)
tex.update_idletasks()
checkLoad.append('a')
示例12: selectFiles
def selectFiles():
fnameEncode = tkFileDialog.askopenfilenames(filetypes=[('Excel file', '*.xls;*.xlsx')], multiple=1)
#sysencode = sys.getfilesystemencoding()
#fnameDecode = fnameEncode.encode(sysencode)
#fnameTmpArray = root.tk.splitlist(fnameEncode)
#fnameArray = [unicode(i, encoding=sysencode) for i in fnameTmpArray]
print fnameEncode
示例13: changeLbox
def changeLbox(self, mytab):
root = gFunc.getRoot(mytab)
mynewdata = tfgiag.askopenfilenames(parent=root,title='Choose a file',filetypes=[('CSV files', '.csv')])
vals = []
self.mainEventBox["values"] = vals
if mynewdata:
#reset old variables
self.pb.start()
self.data.maindata = pd.DataFrame()
self.lbox.delete(0, self.lbox.size())
#populate lists and data
for myfile in root.tk.splitlist(mynewdata):
foo = pd.read_csv(myfile, error_bad_lines=False)
if (self.data.maindata.empty):
self.data.setMainData(foo)
else:
self.data.appendMainData(foo)
eventlist = []
for eventID in foo["Event ID"].unique():
self.lbox.insert(END, eventID)
eventlist.append(eventID)
vals.append(eventID)
print myfile
self.mainEventBox["values"] = vals
self.mainEventBox.set(vals[0])
self.pb.stop()
else:
print "Cancelled"
return mynewdata
示例14: merge_dictionaries
def merge_dictionaries():
global student_dict,student
#Similar code as above, although the point here would be to merge past student grades dictionary
# with the sample transcript
name=askopenfilenames()
student_data=[] # Will contain a list of tuples with selected student names and name of files
student_info={}
for i in range(len(name)):
address=name[i]
filename=""
for i in range(len(address)-1,-1,-1):
if address[i]=='/':
break
filename+=address[i]
filename=filename[::-1].encode('ascii')
student_name=filename.split('.')[0].encode('ascii')
student_data.append((student_name, filename))
for student_name,filename in student_data:
student_info.setdefault(student_name,{})
student_info[student_name]=grades_dictionary(filename)
#Here we are able to extract the user/student name that we will merge with past student grades
# Effectively we create one dictionary with all the data we need
student = student_data[0][0]
student_dict[student]=student_info[student]
print student_dict
示例15: browseFiles
def browseFiles(self):
longFileNameList = tkFileDialog.askopenfilenames(initialdir=self.currentFileDir, title="Load files")
longFileNameList = list(self.parent.tk.splitlist(longFileNameList))
if longFileNameList:
longFileNameList = [os.path.normpath(p) for p in longFileNameList]
self.currentFileDir = os.path.dirname(longFileNameList[0])
self.loadFiles(longFileNameList)