class searchDialog(Toplevel): def __init__(self, parent, title): self.top = Toplevel(parent) self.top.wm_title(title) self.top.wm_minsize(width=300, height=400) self.top.bind("<Return>", self.searchThreader) self.top.bind("<Escape>", self.close) self.searchy = Text(self.top) self.searchy.config(wrap=WORD) self.search_entry = Entry(self.top) self.close = Button(self.top, text="Close", command=self.close) self.search_button = Button(self.top, text="Search", command=self.searchThreader) self.scrollbar = Scrollbar(self.top) self.scrollbar.pack(side=RIGHT, fill=Y, expand=0) self.searchy.config(yscrollcommand=self.scrollbar.set, state=DISABLED) self.searchy.pack(side=TOP, fill=BOTH, expand=1) self.search_entry.pack(side=LEFT, fill=X, expand=1) self.close.pack(side=RIGHT, fill=BOTH, expand=0) self.search_button.pack(side=RIGHT, fill=BOTH, expand=0) self.linker = HyperlinkManager(self.searchy) def close(self, event=None): global SEARCH SEARCH = None self.top.destroy() def putText(self, text): updateDisplay(text, self.searchy, self.linker) def clearSearch(self): self.searchy.config(state=NORMAL) self.searchy.delete(1.0, END) self.searchy.config(state=DISABLED) def searchThreader(self, event=None, text=None): self.sear = upThread(6, 'search', (self, text)) self.sear.start() def search(self, toSearch=None): if toSearch is None: keyword = self.search_entry.get() self.search_entry.delete(0, END) else: keyword = toSearch self.clearSearch() self.top.wm_title("Search - " + keyword) if keyword.split('@')[0] == '': self.putText( API.GetUserTimeline( screen_name=keyword.split('@')[1] ) ) else: self.putText(API.GetSearch(term=keyword))
class conDialog(Toplevel): def __init__(self, parent, title): self.top = Toplevel(parent) self.top.wm_title(title) self.top.wm_minsize(width=200, height=250) self.parent = parent self.logger = Text(self.top, width=50, height=15) self.logger.pack(fill=BOTH, expand=1) self.logger.config(wrap=WORD) self.close = Button(self.top, text="Close", command=self.close) self.close.pack(fill=X, expand=0) self.close.focus() self.logger.tag_config('backlog', foreground="grey") self.logger.tag_config('ERR', foreground="IndianRed1") for e in range(len(ERR)): if len(ERR[e][1]) > 1: self.logger.insert(INSERT, str(ERR[e][0] + "\n"), ERR[e][1]) else: self.logger.insert(INSERT, str(ERR[e] + '\n'), 'backlog') self.logger.config(state=DISABLED) # destroys this Toplevel widget and sets the CON variable to None def close(self): self.top.destroy() global CON CON = None # method that places the text inside the log thats in the console # also stores the messages in the backlog (ERR) def placeText(self, message): self.logger.config(state=NORMAL) ERR.append(message) if len(message[1]) > 1: self.logger.insert(INSERT, str(message[0] + "\n"), message[1]) else: self.logger.insert(INSERT, message + "\n") self.logger.config(state=DISABLED)