Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@NickHurst
Last active September 25, 2015 15:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickHurst/8e005ac6697afe05e82d to your computer and use it in GitHub Desktop.
Save NickHurst/8e005ac6697afe05e82d to your computer and use it in GitHub Desktop.
Displays the current hot posts on /r/ShowerThoughts via tkinter
import praw
import Tkinter as tk
class ShowerThoughtsDisplay(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
# set it to full screen, works on linux but not on OS X, untested on Windows
self.attributes('-fullscreen', True)
# sets it to full screen (but windowed) on OS X
self.geometry("{0}x{1}+0+0".format(self.winfo_screenwidth(), self.winfo_screenheight()))
self.v = tk.StringVar()
tk.Label(self, textvariable=self.v, wraplength=500, font=('Arial', 24)).pack()
self.r = praw.Reddit('shower-thoughts-display')
self.sub = self.r.get_subreddit('showerthoughts')
def getPosts(self):
submissions = self.sub.get_hot()
for subm in submissions:
s = '"{}"\nby: {}'.format(str(subm.title.encode('utf-8')),
str(subm.author).encode('utf-8'))
self.v.set(s)
self.update()
self.after(30000, None)
self.after(10, self.getPosts)
def main():
app = ShowerThoughtsDisplay()
app.after(0, app.getPosts)
app.mainloop()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment