-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzza.py
54 lines (44 loc) · 2.6 KB
/
zza.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
# --------------
# Imports
# --------------
import os
from os import startfile
import random
import glob
from tkinter import *
# --------------
# WINDOW <- Window
# --------------
window = Tk() # Create blank window
window.geometry('300x150') # Set window size
window.title("ranMediaFind") # Window Title
windowTitle = Label(window, text="Open random jonVid") # Create Label
windowTitle.pack() # Set label location
# --------------
# BUTTON <- Button
# --------------
def genBtn(): # Define button press command
# --------------
# Find random .jonVid <- Find random .jonVid
# --------------
vids = [] # Create list
for jonVid in glob.glob("./media/**/*.jonVid", recursive = True): # Grab all files inside ./media with the file extension .jonVid
vids.append(jonVid) # Pack every occurance into the list vids
rFile = vids[random.randint(0, len(vids))] # Grab random vid from list
print(rFile) # Print random vid
windowTitle.configure(text="Opening: \n" + # Display button press
(os.path.splitext(os.path.basename(rFile))[0])) # Shows the name of file opened with out the directory or the file extension
startfile(rFile) # Open random vid
gen = Button(window, text="Generate", command=genBtn) # Display generate button
gen.pack() # Allign button
# --------------
# TEXT BOX <- Text box
# --------------
findTitle = Label(window, text="\nFind jonVid") # Create new label with the text Find jonVid
findTitle.pack() # Allign new label
find = Entry(window, width=10) # Create text box
find.pack() # Allign new text box
# --------------
# DISPLAY WINDOW <- Display window
# --------------
window.mainloop() # Start window