My application have a window which handle key press events. When user press a key I run some long tasks and during a task I update a label on the window. To update the label while task is still running I call the following code.
while gtk.events_pending():
    gtk.main_iteration(False)
This update the label but problem is that it process all the events including key presses. if user press a key while a tasks is running calling main_iteration start processing that task. I want that it should only update the label but any other events should not be processed . Those events should be processed when task is completed.
One way to do this is to remove the key press handler or with in that keypress handler check if task is running then ignore the key presses but in this way keypresses will be lost. I want that somehow it should only update the label but leave other events and those events should be handled after task is completed and application become idle.  Is there a way to do this?
Thanks
You want the .queue_draw() and related GtkWidget methods. Note that these will mark your widget as needing redraw when you get back to the main loop; I don't think GTK+ has a method for drawing right now (but marking as dirty and letting the system redraw when it's ready is usually better for optimization reasons).
How to redraw gtk widget in python without calling gtk.main_iteration?