forked from sandeepraju/git-talk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI.py
148 lines (119 loc) · 5.04 KB
/
GUI.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
from Tkinter import *
import tkFileDialog
import os
class GUI(Frame):
def __init__(self):
self.root = Tk()
self.v1 = IntVar()
self.v2 = IntVar()
self.file_title = StringVar()
self.file_path = ''
self.file_url = ''
self.root.title('GitTalk')
# TITLE FRAME
title_frame = Frame(self.root)
Label(title_frame, justify=LEFT, text='Enter recording title').pack(side=LEFT)
Entry(title_frame, textvariable=self.file_title, width=15).pack(side=LEFT)
title_frame.pack(side=TOP, anchor=W, expand=1, fill=X)
# -----------
# OPTION FRAME
option_frame = Frame(self.root)
Label(option_frame, justify=LEFT, text='Select an option').pack(side=TOP, anchor=W)
Radiobutton(option_frame, text='Existing file', padx=15, variable=self.v1, value=1, command=self.popup_browse).pack(anchor=W, side=TOP)
Radiobutton(option_frame, text='Existing url', padx=15, variable=self.v1, value=2, command=self.popup_url).pack(anchor=W, side=TOP)
Radiobutton(option_frame, text='New recording', padx=15, variable=self.v1, value=3, command=self.popup_record).pack(anchor=W, side=TOP)
option_frame.pack(side=TOP, anchor=W, expand=1, fill=BOTH)
# -----------
# BUTTON FRAME
button_frame = Frame(self.root)
Button(button_frame, text='Finish', command=self.done).pack(side=RIGHT)
Button(button_frame, text='Cancel', command=self.root.destroy).pack(side=RIGHT)
button_frame.pack(side=TOP, anchor=W, expand=1, fill=X)
# -----------
self.root.mainloop()
def done(self):
val = self.v1.get()
title = self.file_title.get()
if title == '':
title = 'Default title here'
print 'Title: '+title
if val == 0:
print 'No option selected'
if val == 1:
print 'Using file: '+self.file_path
if val == 2:
print 'Using url: '+self.file_url
if val == 3:
print 'Using recorded file '+self.file_url
# TODO: PASS FILE_PATH TO UPLOAD_YOUTUBE OR PASS FILE_URL TO GIT HOOK
self.root.destroy()
# FILE SELECTION FUNCTIONS
# -----------------------------------------------------------
def popup_browse(self):
self.browse_window = Tk()
self.browse_window.title('Enter file path')
self.path_entry = Entry(self.browse_window, width=30)
self.path_entry.pack(side=LEFT, padx=5, pady=5)
Button(self.browse_window, text='Browse', command=self.ask_open_filename).pack(side=LEFT, padx=5)
Button(self.browse_window, text='Use', command=self.destroy_browse).pack(side=LEFT, padx=5)
self.browse_window.mainloop()
def ask_open_filename(self):
self.file_opt = {# 'defaultextension': '.mp4',
'filetypes': [
('All files', '.*'),
('MPEG 4', '.mp4'),
('Windows Media Video', '.wmv'),
('Web Media', '.webm'),
('Flash Video', '.flv'),
('Matroska Video', '.mkv'),
('Quick Time Video', '.mov')
],
'initialdir': os.getcwd(),
'parent': self.browse_window,
'title': 'Select a video file to upload'}
self.path = tkFileDialog.askopenfilename(**self.file_opt)
self.path_entry.insert(0, self.path)
def destroy_browse(self):
self.file_path = self.path_entry.get()
self.browse_window.destroy()
# -----------------------------------------------------------
# URL FUNCTIONS
# -----------------------------------------------------------
def popup_url(self):
self.url_window = Tk()
self.url_window.title('Enter URL')
self.url_entry = Entry(self.url_window, width=30)
self.url_entry.pack(side=LEFT, padx=5, pady=5)
Button(self.url_window, text='Use', command=self.destroy_url).pack(side=LEFT)
self.url_window.mainloop()
def destroy_url(self):
self.file_url = self.url_entry.get()
self.url_window.destroy()
# -----------------------------------------------------------
# RECORD FUNCTIONS
# -----------------------------------------------------------
def popup_record(self):
record_window = Tk()
record_window.title('Record')
option_frame2 = Frame(record_window)
Radiobutton(option_frame2, text='Audio & Screen Capture', padx=15, variable=self.v2, value=1).pack(anchor=NW, side=TOP)
Radiobutton(option_frame2, text='Audio & Screen Capture', padx=15, variable=self.v2, value=2).pack(anchor=NW, side=TOP)
Radiobutton(option_frame2, text='Audio & Screen Capture', padx=15, variable=self.v2, value=3).pack(anchor=NW, side=TOP)
self.status = Label(record_window, text='Ready', justify=LEFT)
self.status.pack(side=TOP, anchor=W)
button_frame2 = Frame(record_window)
Button(button_frame2, text='Stop', command=self.stop_record).pack(side=RIGHT)
Button(button_frame2, text='Start', command=self.start_record).pack(side=RIGHT)
button_frame2.pack(side=TOP, anchor=W, expand=1, fill=X)
record_window.mainloop()
def start_record(self):
# TODO: CHECK IF ALREADY RECORDED - ASK FOR OVERWRITE
self.status.config(text='Recording..')
print 'RECORD HERE'
def stop_record(self):
# TODO: GET FILE PATH AND PASS IT TO UPLOADING FUNCTION
self.status.config(text='Done')
print 'STOP RECORDING HERE'
# -----------------------------------------------------------
if __name__ == '__main__':
window = GUI()