-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandom Picker.py
More file actions
87 lines (63 loc) · 2.55 KB
/
Copy pathRandom Picker.py
File metadata and controls
87 lines (63 loc) · 2.55 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Libraries
import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox
import random
import os
# Initializing the window settings
title = "Game Picker"
sub = "Pick a list to find out the next game you'll play!"
root = tk.Tk()
root.title("Game Picker 1.0")
X = 800
Y = 300
main_screen = tk.Canvas(root, width = X, height = Y, relief = 'raised', bg = "black")
main_screen.pack()
# Initializing the file picker
ROM = ""
ROM_list = ""
# Functions
def getList(ready_list=None):
global ROM
global ROM_list
try:
if ready_list == None:
ROM_list = filedialog.askopenfilename(filetypes=[("Lists", ".txt")])
ROM = picker(ROM_list)
else:
ROM = picker(ready_list)
cleaner = tk.Label(root, text=" ", fg= "white", bg="black")
cleaner.config(font=('helvetica', 30))
main_screen.create_window(X//2, Y-120, window=cleaner)
main_screen.create_window(X//2, Y-50, window=cleaner)
ROM_status = tk.Label(root, text=ROM, fg= "white", bg="black")
ROM_status.config(font=('helvetica', 18))
main_screen.create_window(X//2, Y-50, window=ROM_status)
if ROM != "":
main_screen.create_window(X//3, Y-120, window=redoButton)
main_screen.create_window(X//3*2, Y-120, window=okButton)
except AttributeError:
pass
def picker(list_file):
try:
with open(list_file) as f:
return (random.choice(f.readlines()))
except:
pass
def reroll():
global ROM_list
getList(ROM_list)
# Initializing the labels
title_label = tk.Label(root, text=title, fg= "white", bg="black")
title_label.config(font=('helvetica', 30))
sub_label = tk.Label(root, text=sub, fg= "white", bg="black")
sub_label.config(font=('helvetica', 18))
browseButton = tk.Button(text="Import List", command=getList, bg='royalblue', fg='white', font=('helvetica', 12, 'bold'))
redoButton = tk.Button(text="Reroll!", command=reroll, bg='royalblue', fg='white', font=('helvetica', 12, 'bold'))
okButton = tk.Button(text="Ok!", command=exit, bg='royalblue', fg='white', font=('helvetica', 12, 'bold'))
# Drawing the window
main_screen.create_window(X//2, 50, window=title_label)
main_screen.create_window(X//2, 100, window=sub_label)
main_screen.create_window(X//2, Y-120, window=browseButton)
#print(random.choice(os.listdir()))
root.mainloop()