Last active
September 25, 2015 15:03
-
-
Save NickHurst/8e005ac6697afe05e82d to your computer and use it in GitHub Desktop.
Displays the current hot posts on /r/ShowerThoughts via tkinter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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