On Monday, January 30, 2017 at 12:02:40 PM UTC+5:30, Meeran Rizvi wrote: > Hello Guys, > Here i am creating a GUI which will act as a search engine that will find the > results from the browser and save the results as a xls file. > When i typed something in my search box and click the (GO)button.It should > display search in progress.when the file is saved it should display done. > How to do that? > My button gets hung for a seconds.We should give any timeout for that? > > Here is my script > <python> > from Tkinter import * > import mechanize > def clear_search(event): > search.delete(0,END) > obj = Tk() > Label = Label(obj,text="Top Findings:",font="-weight bold") > search = Entry(obj,width=100) > search.insert(0, "Enter the value to search") > search.bind("<Button-1>", clear_search) > def fun(): > new = search.get() > url = "http://duckduckgo.com/html" > br = mechanize.Browser() > br.set_handle_robots(False) > br.open(url) > br.select_form(name="x") > br["q"] = str(new) > res = br.submit() > content = res.read() > with open("result1.xls", "w") as f: > f.write(content) > fun() > Go = Button(obj,text="GO",width=5,command=fun) > Label.pack() > search.pack() > Go.pack() > mainloop() > </python>
Hi Peter, can u explain about these functions def start_search(): thread = threading.Thread( target=fun, args=(search.get(),) ) thread.setDaemon(True) thread.start() root.after(100, check_state) def check_state(): while True: try: message = queue.get_nowait() except Queue.Empty: break state_info["text"] = message if message == "done": return root.after(100, check_state) -- https://mail.python.org/mailman/listinfo/python-list