久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='JEJ0C'></tfoot>

      <small id='JEJ0C'></small><noframes id='JEJ0C'>

      • <bdo id='JEJ0C'></bdo><ul id='JEJ0C'></ul>

      <legend id='JEJ0C'><style id='JEJ0C'><dir id='JEJ0C'><q id='JEJ0C'></q></dir></style></legend>

      <i id='JEJ0C'><tr id='JEJ0C'><dt id='JEJ0C'><q id='JEJ0C'><span id='JEJ0C'><b id='JEJ0C'><form id='JEJ0C'><ins id='JEJ0C'></ins><ul id='JEJ0C'></ul><sub id='JEJ0C'></sub></form><legend id='JEJ0C'></legend><bdo id='JEJ0C'><pre id='JEJ0C'><center id='JEJ0C'></center></pre></bdo></b><th id='JEJ0C'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JEJ0C'><tfoot id='JEJ0C'></tfoot><dl id='JEJ0C'><fieldset id='JEJ0C'></fieldset></dl></div>

        如何在 Kivy GUI 旁邊運(yùn)行 Tornado 事件循環(huán)?

        How to run the Tornado event loop alongside a Kivy GUI?(如何在 Kivy GUI 旁邊運(yùn)行 Tornado 事件循環(huán)?)

          <small id='l4OLb'></small><noframes id='l4OLb'>

          <tfoot id='l4OLb'></tfoot>
          • <bdo id='l4OLb'></bdo><ul id='l4OLb'></ul>
            1. <i id='l4OLb'><tr id='l4OLb'><dt id='l4OLb'><q id='l4OLb'><span id='l4OLb'><b id='l4OLb'><form id='l4OLb'><ins id='l4OLb'></ins><ul id='l4OLb'></ul><sub id='l4OLb'></sub></form><legend id='l4OLb'></legend><bdo id='l4OLb'><pre id='l4OLb'><center id='l4OLb'></center></pre></bdo></b><th id='l4OLb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='l4OLb'><tfoot id='l4OLb'></tfoot><dl id='l4OLb'><fieldset id='l4OLb'></fieldset></dl></div>

                • <legend id='l4OLb'><style id='l4OLb'><dir id='l4OLb'><q id='l4OLb'></q></dir></style></legend>

                    <tbody id='l4OLb'></tbody>
                  本文介紹了如何在 Kivy GUI 旁邊運(yùn)行 Tornado 事件循環(huán)?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我的客戶端應(yīng)用程序使用 Kivy GUI(Kivy 有自己的事件循環(huán))并使用帶有 Tornado 的 WebSocket 協(xié)議連接到服務(wù)器(Tornado 也有一個(gè)事件循環(huán)).這就是連接部分是異步的原因.我希望用戶在 Tornado 客戶端運(yùn)行無(wú)限異步循環(huán)以偵聽(tīng)服務(wù)器消息時(shí)與 UI 交互.

                  My client application uses a Kivy GUI (Kivy has its own event loop) and connects to the server using the WebSocket protocol with Tornado (Tornado also has an event loop). That's why the connection part is asynchronous.
                  I want the user to interact with the UI while a Tornado client is running an infinite asynchronous loop of listening for server messages.

                  以下是一些示例代碼:
                  client_test.py

                  from tornado.ioloop import IOLoop
                  from tornado.websocket import websocket_connect
                  
                  class RequestSender:
                      url = 'server url here (no scheme)'
                  
                      async def _connect(self):
                          self.conn = await websocket_connect('wss://' + self.url, io_loop=self.ioloop)
                          self.ioloop.add_callback(self._listen)
                  
                      async def _listen(self):
                          while True:
                              print(await self.conn.read_message())
                  
                      def __init__(self):
                          self.ioloop = IOLoop.current()
                          self.ioloop.add_callback(self._connect)
                  
                      def run(self):
                          self.ioloop.start()
                  

                  圖形界面

                  from kivy.app import App
                  from kivy.uix.label import Label
                  from client_test import RequestSender
                  
                  class TestApp(App):
                      def build(self):
                          RequestSender().run()
                          return Label(text = "hello")
                  
                  TestApp().run()
                  

                  顯然,由于 Tornado 的事件循環(huán)已經(jīng)開(kāi)始較早,它已經(jīng)接管了程序流程,現(xiàn)在沒(méi)有出現(xiàn) GUI 窗口.
                  我執(zhí)行 GUI 文件,在 RequestSender().run() 之后執(zhí)行掛起,因此 build 永遠(yuǎn)不會(huì)返回.

                  Apparently, since the Tornado's event loop has started earlier, it has taken over the program flow and now no GUI window appears.
                  I execute the GUI file and the execution hangs after the RequestSender().run(), so build never returns.

                  搜索此案例幾乎沒(méi)有提供任何信息,除了 thisGoogle 網(wǎng)上論壇帖子.Kivy 的文檔僅提及 Twisted.

                  Searching on this case provided little to no information, except for this Google Groups post. Kivy's documentation only mentions Twisted.

                  我嘗試將 Kivy 事件循環(huán)置于從屬模式并從 Tornado 的事件循環(huán)運(yùn)行 GUI 更新,但這不起作用,因?yàn)轱@然 Kivy 的事件循環(huán)的調(diào)用 EventLoop.idle() 不是足以保持 GUI 應(yīng)用程序運(yùn)行.

                  I tried putting the Kivy event loop into slave mode and running GUI updates from Tornado's event loop, but that didn't work because apparently a call EventLoop.idle() of Kivy's event loop isn't enough to keep the GUI application running.

                  這里還能做什么?

                  推薦答案

                  我發(fā)現(xiàn)這個(gè)問(wèn)題試圖做同樣的事情,并選擇了兩個(gè)單獨(dú)的進(jìn)程;一個(gè) Kivy GUI 和一個(gè) Tornado(在我的例子中是服務(wù)器).我有兩個(gè)使用 multiprocessing.connection 進(jìn)行通信,如 this SO answer 中所述

                  I found this question trying to do the same thing, and opted for two separate processes instead; one Kivy GUI and one Tornado (Server, in my case). I have the two communicate using multiprocessing.connection as explained well in this SO answer

                  如果您要在兩者之間傳遞大量而復(fù)雜的數(shù)據(jù),這可能不太理想,但對(duì)于簡(jiǎn)單的消息來(lái)說(shuō)效果很好.您還可以在沒(méi)有 UI 的情況下運(yùn)行,并在單獨(dú)的計(jì)算機(jī)上運(yùn)行 UI.

                  If you have large and complex data to pass between the two, perhaps this is less than ideal, but for simple messages it works well. You also have the advantage of running without the UI, and running the UI on a separate machine.

                  這篇關(guān)于如何在 Kivy GUI 旁邊運(yùn)行 Tornado 事件循環(huán)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個(gè)在 Python 中提供角色的不和諧機(jī)器人?)
                  Discord bot isn#39;t responding to commands(Discord 機(jī)器人沒(méi)有響應(yīng)命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關(guān)于我嗎?Discord 機(jī)器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機(jī)器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動(dòng)更改角色顏色)

                  • <tfoot id='1lz49'></tfoot>

                        <i id='1lz49'><tr id='1lz49'><dt id='1lz49'><q id='1lz49'><span id='1lz49'><b id='1lz49'><form id='1lz49'><ins id='1lz49'></ins><ul id='1lz49'></ul><sub id='1lz49'></sub></form><legend id='1lz49'></legend><bdo id='1lz49'><pre id='1lz49'><center id='1lz49'></center></pre></bdo></b><th id='1lz49'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1lz49'><tfoot id='1lz49'></tfoot><dl id='1lz49'><fieldset id='1lz49'></fieldset></dl></div>
                        <legend id='1lz49'><style id='1lz49'><dir id='1lz49'><q id='1lz49'></q></dir></style></legend>
                        • <bdo id='1lz49'></bdo><ul id='1lz49'></ul>

                            <small id='1lz49'></small><noframes id='1lz49'>

                              <tbody id='1lz49'></tbody>
                            主站蜘蛛池模板: 在线日韩中文字幕 | 国产精品二区三区在线观看 | 久久久日韩精品一区二区三区 | 久久av一区 | 91在线一区| 欧美一区二区三区大片 | 午夜视频在线 | 午夜精品一区二区三区免费视频 | 欧美一区二区三区的 | 欧美一区不卡 | 91社区在线观看 | 久久久久久国产精品三区 | 狠狠操狠狠操 | 成人精品一区二区户外勾搭野战 | 天堂综合网久久 | 国产日韩久久 | 一区二区三区四区在线视频 | a级片在线 | 蜜桃视频在线观看免费视频网站www | 精品少妇一区二区三区日产乱码 | 激情亚洲 | 精品粉嫩aⅴ一区二区三区四区 | 激情毛片| 国产精品视频一区二区三区 | 国产精品视频不卡 | 亚洲成人综合网站 | 精品亚洲国产成av人片传媒 | 天堂网中文字幕在线观看 | 久久综合色综合 | 久久久91精品国产一区二区三区 | 免费一区二区 | 欧美精品在线免费 | 国产精品亚洲一区二区三区在线 | 午夜影院免费体验区 | 亚洲日韩中文字幕一区 | 免费a v网站 | 欧美日韩一区二区在线观看 | 欧美专区在线 | 欧美日韩三级在线观看 | 中文字幕成人在线 | 91成人午夜性a一级毛片 |