Display a label while pressing the button in my GUI
__peter__ at web.de
Mon Jan 30 04:31:01 EST 2017
hmmeeranrizvi18 at gmail.com 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?
Move the actual processing into another thread and have it communicate with
your GUI through a Queue. Here's a sketch:
from Tkinter import *
thread = threading.Thread(
url = "http://duckduckgo.com/html"
br = mechanize.Browser()
br["q"] = str(new)
res = br.submit()
content = res.read()
with open("result1.xls", "w") as f:
message = queue.get_nowait()
state_info["text"] = message
if message == "done":
queue = Queue.Queue()
root = Tk()
top_findings = Label(root, text="Top Findings:", font="-weight bold")
search = Entry(root, width=100)
search.insert(0, "Enter the value to search")
# Did you see Christian Gollwitzer's post?
go_button = Button(root, text="GO", width=5, command=start_search)
state_info = Label(root)
More information about the Python-list