[Tkinter-discuss] Simulating keystrokes in a tkinter unit test
Michael Lange
klappnase at web.de
Fri Feb 2 04:47:55 EST 2018
Hi,
On Thu, 1 Feb 2018 23:52:34 -0600
alan moore <me at alandmoore.com> wrote:
> Thanks. I managed to work it out. I think the problem was twofold:
>
> - I needed to call self.mywidget.focus_force(), because my test root
> wasn't getting focus
> - I needed to call self.root.update() before *and* after the key events
>
> This got it working.
Here (debian linux) the test also works if I just change the setUp()
method like this:
def setUp(self):
super().setUp()
self.mywidget = self.create()
self.mywidget.wait_visibility()
self.mywidget.update_idletasks()
self.mywidget.focus_set()
Regards
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
Is not that the nature of men and women -- that the pleasure is in the
learning of each other?
-- Natira, the High Priestess of Yonada, "For the World is
Hollow and I Have Touched the Sky", stardate 5476.3.
More information about the Tkinter-discuss
mailing list