~nhanb/mcross

9ff8648065a0fc0c2c0061f5da52d4a58320a6b3 — Bùi Thành Nhân 11 months ago dd33400
more responsive UI, full disclosure
3 files changed, 14 insertions(+), 4 deletions(-)

M README.md
M pyproject.toml
M src/mcross/gui/controller.py
M README.md => README.md +5 -2
@@ 81,8 81,11 @@ completely loaded. That is A Bad Thing (tm).
## Lightweight

In terms of both disk space & memory/cpu usage.
It's completely unoptimized at the moment but tkinter and zero-dependency
python gives us a fairly good starting point imo.
It's completely unoptimized at the moment.
Actually the way I'm hooking up tkinter and curio is... not ideal. See comments
in controller.py for more info. TL;DR I'm prioritizing gui responsiveness and
code simplicity, sacrificing a non-negligible amount of CPU cycles even at
idle.


# Server bugs/surprises

M pyproject.toml => pyproject.toml +1 -1
@@ 1,6 1,6 @@
[tool.poetry]
name = "mcross"
version = "0.5.2"
version = "0.5.3"
description = "Do you remember www?"
authors = ["nhanb <hi@imnhan.com>"]
license = "MIT"

M src/mcross/gui/controller.py => src/mcross/gui/controller.py +8 -1
@@ 58,7 58,14 @@ class Controller:
                    for coroutine in self.pending_coros:
                        await coroutine
                    self.pending_coros = []
                    await curio.sleep(0.05)  # 50ms
                    await curio.sleep(0.016)
                    # 16ms = 1/60 - we're targeting around 60fps
                    # Yes it's wasteful to call root.update() that fast.
                    # In practice CPU usage idles around 4% on my i5 but hey it's not
                    # spinning up my laptop fans yet.
                    # Doesn't seem like there's a better way atm. The alternative
                    # described at [1] is multithreading which I'm not a fan of.
                    # [1] https://github.com/dabeaz/curio/issues/111
            except TclError as e:
                if "application has been destroyed" not in str(e):
                    raise