I am trying (for testing) to have a little ascii spinner object being printed on the screen during a gtk.main() loop. Currently, I have this code which prints a dot every two seconds.
gobject.timeout_add(2 * 1000,
lambda : (sys.stdout.write('.'), sys.stdout.flush()) )
gtk.main()
However, I would like the traditional ascii spinner instead but cannot get a good lambda for it. Any suggestions?
Edit: Two good answers but is there a way to do this with a lambda? Just ’cause lambda are cool. Nothing more.
Why are you limiting yourself to a
lambda? To do a spinner, it’s easiest to maintain state:Note: the above is untested, but should make the general idea clear enough.