Message271228
OK, I'm playing with this too. I merged your loop_tk.py example with crawl.py and am attaching the result as tkcrawl.py. I don't like global state so I added root and loop as parameters to a few places. Hopefully you have the asyncio repo checked out so you can compare this with the original crawl.py -- it basically has your code (with globals replaced by locals or instance variables) and these three lines in main() once loop is set:
+ root = tk.Tk()
+ t = asyncio.Task(display_date(root, loop, 100, 1))
+ tk_update(root, loop)
and a loop.run_forever() call just before the loop.close() call, to keep the app running once it's done.
There are also two imports near the top (datetime and tkinter as tk).
(Oh, and I just realized I made some changes to crawl.py to suppress displaying the URL of every HTML page retrieved when -q is given. I will commit that.)
Running this will display the widget with the hello label and the button to change the color, *and* update the date every second, and it's totally responsive, all *while* it is fetching contents from e.g. xkcd.com. |
|
Date |
User |
Action |
Args |
2016-07-25 04:47:35 | gvanrossum | set | recipients:
+ gvanrossum, terry.reedy, serhiy.storchaka, yselivanov, Maxime S |
2016-07-25 04:47:34 | gvanrossum | set | messageid: <1469422054.46.0.387164218032.issue27546@psf.upfronthosting.co.za> |
2016-07-25 04:47:34 | gvanrossum | link | issue27546 messages |
2016-07-25 04:47:34 | gvanrossum | create | |
|