On Monday, January 30, 2017 at 8:26:07 PM UTC+5:30, Meeran Rizvi wrote: > On Monday, January 30, 2017 at 8:19:47 PM UTC+5:30, Peter Otten wrote: > > Meeran Rizvi wrote: > > > > > 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> > > > > > > It is possible to display the output in my GUI itself? > > > > Instead of the strings "searching", "writing result", and "done" you could > > put search results into the queue and display them in a Text widget. To > > signal when you're done you can use an out-of-band value, typically None. > > > > See also <http://effbot.org/zone/tkinter-threads.htm>. > > I just want to save it as a xls file and also from xls file i need to get the > data and display in a text box.
Or either i just display the output in my text widget and also save it as an xls file -- https://mail.python.org/mailman/listinfo/python-list