-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgui.py
More file actions
64 lines (50 loc) · 2.06 KB
/
gui.py
File metadata and controls
64 lines (50 loc) · 2.06 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import tkinter as tk
from tkinter.filedialog import askopenfilename
from tkinter.messagebox import showinfo
import moscg
from pathlib import Path
class GUI(tk.Tk):
filename = ''
def __init__(self):
super().__init__()
self.title("moscg")
self.clusters = tk.IntVar(value=4)
self.skip_frames = tk.IntVar(value=99)
self.save_adj = tk.IntVar(value=0)
self.desc = tk.StringVar()
self.draw()
def select_file(self):
self.filename = askopenfilename(
title='Open a file',
initialdir='.')
def run(self):
if self.filename == '':
showinfo("Error", "Select a video file!")
else:
foo = moscg.Moscg(Path(self.filename), self.clusters.get(), self.skip_frames.get(), self.save_adj.get())
foo.run()
def draw(self):
self.desc.set("Movie screen grabber. Choose a movie file to proceed.")
lbl_desc = tk.Label(textvariable=self.desc)
lbl_cluster = tk.Label(text="Number of screenshots:")
lbl_skip = tk.Label(text="Number of skipped frames:")
lbl_adj = tk.Label(text="Number of additional adjacent frames to save:")
ent_cluster = tk.Entry(textvariable=self.clusters)
ent_skip = tk.Entry(textvariable=self.skip_frames)
ent_adj = tk.Entry(textvariable=self.save_adj)
btn_file = tk.Button(text="Select movie file", command=self.select_file)
btn_run = tk.Button(text="Run", command=self.run)
lbl_desc.grid(row=0, column=0, padx=5, pady=5)
lbl_cluster.grid(row=1, column=0, padx=5, pady=5)
ent_cluster.grid(row=1, column=1, padx=5, pady=5)
lbl_skip.grid(row=2, column=0, padx=5, pady=5)
ent_skip.grid(row=2, column=1, padx=5, pady=5)
lbl_adj.grid(row=3, column=0, padx=5, pady=5)
ent_adj.grid(row=3, column=1, padx=5, pady=5)
btn_file.grid(row=4, column=0, padx=5, pady=5)
btn_run.grid(row=4, column=1, padx=5, pady=5)
def main_fct():
gui = GUI()
gui.mainloop()
if __name__ == '__main__':
main_fct()