
Nov. 27, 2014
1:18 p.m.
On Thu, Nov 27, 2014 at 7:39 AM, Stefano Borini < stefano.borini@ferrara.linux.it> wrote:
with contextlib.context(enter=None, exit=lambda *args: my_widget.setFocus()): do what I need to do
You can easily define your own context manager to do what you want: @contextmanager def finally_focus(widget): try: yield finally: widget.setFocus() with finally_focus(my_widget): # do what I need to do -- Juancarlo *Añez*