Event loop implementation for Python 3?

前端 未结 2 819
耶瑟儿~
耶瑟儿~ 2021-01-07 00:45

Does anyone know of an event loop library (or bindings) available for Python 3? It\'s okay if it only does UNIX systems, though I would prefer something that does Windows a

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-07 01:22

    I suggest something like:

    while True:
        while queue:
            queue.pop()()
    

    For that to work, however, you need to have the event system put callable events onto the queue.

    (If you are more interested in a specific binding to a specific framework, such as GTK, Qt, WxWidgets, NCurses, Cocoa, Winforms, whatever, then say that!).

提交回复
热议问题