from Tkinter import * import thread import time # The Popup class class Popup: def __init__(self): def drawALot(): self.root = Tk() self.root.withdraw() self.root.mainloop() thread.start_new_thread(drawALot, ()) def _makeTheWindow(self, item): """ Private method that does the actual window drawing """ root = Toplevel() root.wm_title("News Alert") w = root.winfo_screenwidth()/20 h = root.winfo_screenheight()/4 title = Text(root, padx=5, pady=5, height=3, wrap=WORD, bg="white") title.tag_config("title", foreground="black", font=("helvetica", 12, "bold")) title.tag_config("subject", foreground="black", font=("helvetica", 12, "bold")) title.insert(INSERT, "Title: %s" % item.getTitle(), "title") title.insert(INSERT, "\nSubject: ", "subject") title.insert(INSERT, item.getSubject().rstrip(), "subject") title.config(state=DISABLED, relief = FLAT) title.grid(sticky=W+E) summary = Text(root, padx=10, pady=5, height=15, wrap=WORD, bg="white") summary.tag_config("text", foreground="black", font=("helvetica", 12)) summary.insert(INSERT, item.getSummary().lstrip(), "text") summary.config(state=DISABLED, relief = FLAT) summary.grid(sticky=W+E) link = Text(root, padx=5, pady=5, height=4, bg="white") link.tag_config("url", foreground="blue", font=("helvetica", 10, "bold")) link.insert(INSERT, item.getLink(), "url") link.config(state=DISABLED, relief=FLAT) link.grid(sticky=W+E) def newWindow(self, item): """ Displays a popup with the contents of the NewsStory newsitem """ self.root.after(0, self._makeTheWindow, item)