-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathopen_file.py
More file actions
executable file
·41 lines (31 loc) · 1.19 KB
/
open_file.py
File metadata and controls
executable file
·41 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
'''
Application to calculate the Type-Token Ratio from an input speech sample.
'''
import Tkinter, Tkconstants, tkFileDialog
class TkFileDialog(Tkinter.Frame):
'''
testing out using Tkinter
'''
def __init__(self, root):
Tkinter.Frame.__init__(self, root)
# options for buttons
button_opt = {'fill': Tkconstants.BOTH, 'padx': 5, 'pady': 5}
# define button
Tkinter.Button(self, text='Select Speech Sample',
command=self.askopenfile).pack(**button_opt)
# define options for opening or saving a file
self.file_opt = options = {}
options['defaultextension'] = '.csv'
options['filetypes'] = [('text files', '.csv'), ('text files', '.txt'), ('all files', '*')]
# options['initialdir'] = 'C:\\'
options['initialfile'] = 'sample_utterances.csv'
#options['parent'] = root
options['title'] = 'Select Speech Sample'
def askopenfile(self):
"""Returns an opened file in read mode."""
return tkFileDialog.askopenfile(mode='r', **self.file_opt)
if __name__ == '__main__':
app = Tkinter.Tk()
TkFileDialog(app).pack()
app.mainloop()