-
Notifications
You must be signed in to change notification settings - Fork 0
/
tkgui.py
81 lines (67 loc) · 1.69 KB
/
tkgui.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
import requests
import praw
import tkinter as tk
import RedditPraw as rapi
print("\n=================")
subreddits = [
("CarletonU",0),
("Python",1),
("AskReddit",2),
("Soccer",3),
("worldnews",4)
]
sortby = [
("New",0),
("Hot",1),
("Top",2),
]
root = tk.Tk()
root.minsize(210, 100)
y = tk.IntVar()
v = tk.IntVar()
v.set(0) # initializing the choice
y.set(0)
def ShowChoice():
# print(v.get())
print()
def ShowChoice2():
print()
# print(y.get())
def showSubReds():
sub = v.get()
sortByThis = y.get()
lim=int(entry1.get())
rapi.redditAPI(subreddits[sub][0],sortby[sortByThis][0],lim)
tk.Label(root,
text="Pick a subreddit",
justify = tk.LEFT,
padx = 20).pack()
for val, subr in enumerate(subreddits):
tk.Radiobutton(root,
text=subr[0],
padx = 0,
variable=v,
command=ShowChoice,
value=val).pack(anchor=tk.W)
tk.Label(root,
text="Sort by:",
justify = tk.LEFT,
padx = 40).pack()
for sortval, sort in enumerate(sortby):
tk.Radiobutton(root,
text=sort[0],
padx = 0,
variable=y,
command=ShowChoice2,
value=sortval).pack(anchor=tk.W)
root.title('SubS')#SubSearch
canvas1 = tk.Canvas(root, width = 200, height = 75)
canvas1.pack()
label1 = tk.Label(root,text="# of posts:")
canvas1.create_window(100,20,window=label1)
entry1 = tk.Entry(root)
canvas1.create_window(100, 50, window=entry1)
entry1.insert(5,"5")
btn1 = tk.Button(root, text="Search",command=lambda:showSubReds())
btn1.pack()
root.mainloop()