Added better focus trace.
set_focus uses w.widget instead of w if hasattr(w,'widget').  Probably a bad idea, but the present code has no chance of working.