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

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

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

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

        <bdo id='NHht8'></bdo><ul id='NHht8'></ul>
      <i id='NHht8'><tr id='NHht8'><dt id='NHht8'><q id='NHht8'><span id='NHht8'><b id='NHht8'><form id='NHht8'><ins id='NHht8'></ins><ul id='NHht8'></ul><sub id='NHht8'></sub></form><legend id='NHht8'></legend><bdo id='NHht8'><pre id='NHht8'><center id='NHht8'></center></pre></bdo></b><th id='NHht8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NHht8'><tfoot id='NHht8'></tfoot><dl id='NHht8'><fieldset id='NHht8'></fieldset></dl></div>
      1. 如何同時(shí)運(yùn)行 kivy 和燒瓶應(yīng)用程序?

        How to run kivy and flask apps together?(如何同時(shí)運(yùn)行 kivy 和燒瓶應(yīng)用程序?)
          <bdo id='eDw44'></bdo><ul id='eDw44'></ul>
          <tfoot id='eDw44'></tfoot>
                <tbody id='eDw44'></tbody>
                1. <i id='eDw44'><tr id='eDw44'><dt id='eDw44'><q id='eDw44'><span id='eDw44'><b id='eDw44'><form id='eDw44'><ins id='eDw44'></ins><ul id='eDw44'></ul><sub id='eDw44'></sub></form><legend id='eDw44'></legend><bdo id='eDw44'><pre id='eDw44'><center id='eDw44'></center></pre></bdo></b><th id='eDw44'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eDw44'><tfoot id='eDw44'></tfoot><dl id='eDw44'><fieldset id='eDw44'></fieldset></dl></div>
                2. <legend id='eDw44'><style id='eDw44'><dir id='eDw44'><q id='eDw44'></q></dir></style></legend>

                3. <small id='eDw44'></small><noframes id='eDw44'>

                4. 本文介紹了如何同時(shí)運(yùn)行 kivy 和燒瓶應(yīng)用程序?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我有一個(gè)燒瓶應(yīng)用程序作為服務(wù)器,我有一個(gè) kivy 應(yīng)用程序作為服務(wù)器的前端.如何運(yùn)行燒瓶然后運(yùn)行 ??kivy 應(yīng)用程序以便它們同時(shí)協(xié)同工作?

                  I have a flask app serving as a server and I have a kivy app serving as a front end to a server. How can I run flask and then kivy app so they work together at the same time?

                  Flask 應(yīng)用:

                  from flask import Flask
                  
                  app = Flask(__name__)
                  
                  
                  @app.route('/')
                  def hello():
                      return 'Hello'
                  
                  if __name__ == "__main__":
                      app.run()
                  

                  Kivy 應(yīng)用:

                  from kivy.app import App
                  from kivy.builder import Builder
                  from kivy.uix.screenmanager import Screen, ScreenManager
                  kivy.require('1.10.0')
                  
                  Builder.load_file('kivy.kv')
                  
                  sm = ScreenManager()
                  
                  class MainScreen(Screen)
                      pass
                  
                  class OtherScreen(Screen)
                      pass
                  
                  sm.add_widget(MainScreen(name='main'))
                  sm.add_widget(OtherScreen(name='other'))
                  
                  class MyApp(App):
                      def build(self):
                          return sm
                  
                  
                  MyApp().run()
                  

                  更新:如果有人在使用 apache 實(shí)現(xiàn)網(wǎng)絡(luò)服務(wù)器時(shí)遇到問(wèn)題,請(qǐng)嘗試 docker,我認(rèn)為這是一種更簡(jiǎn)單、更快的解決方案!

                  Update: If someone is having problems implementing a webserver with apache, try docker, simpler and faster solution, in my opinion!

                  推薦答案

                  我想讓 Flask 連續(xù)運(yùn)行.我嘗試了建議的解決方案,按照@amanb 的建議將它們作為線程一起運(yùn)行.我發(fā)現(xiàn) Flask 正在阻塞 Kivy,反之亦然,無(wú)論線程的時(shí)間安排或排列方式如何.原因是解釋器的 GIL.因此,我嘗試了流程,似乎它確實(shí)有效.

                  I wanted Flask to run continuously. I tried the proposed solution to run them together as threads as suggested by @amanb. I found out Flask is blocking Kivy and vice versa no matter the timing or how arranged are the threads. The reason being the interpreter's GIL. Therefore I tried with processes and it seems it does the work.

                  代碼

                  #!/usr/bin/python2.7 python2.7
                  # -*- coding: utf-8 -*-
                  
                  # kivy modules first, if not Kivy may cause problems
                  import kivy
                  from kivy.app import App
                  from kivy.lang import Builder
                  from kivy.uix.label import Label
                  from kivy.uix.floatlayout import FloatLayout
                  from kivy.uix.screenmanager import ScreenManager, Screen
                  kivy.require('1.10.0')
                  
                  
                  # common modules
                  import sys
                  import signal
                  from multiprocessing import Process
                  
                  
                  # Flask & similar modules
                  from flask import Flask
                  from flask_restful import reqparse, abort, Api, Resource
                  import eventlet
                  from eventlet import wsgi
                  
                  
                  # async server setup
                  app = Flask(__name__)
                  api = Api(app)
                  
                  
                  def start_Flask():
                      print("Starting server...")
                      # start an eventlet WSGI server on port 5000
                      wsgi.server(eventlet.listen(('', 5000)), app)     
                  
                  
                  def signal_handler(signal, frame):
                      # for fetching CTRL+C and relatives
                      print " CTRL + C detected, exiting ... "
                      exit(1)
                  
                  
                  # Kivy screen class
                  class MainScreen(Screen):
                      def __init__(self, **kwargs):
                          self.name="MAIN SCREEN"
                          super(Screen, self).__init__(**kwargs)
                  
                  
                  # Kivy app class
                  class Kivy(App):
                      w_MessageBox10_1 = "MAIN SCREEN"
                      w_MessageBox10_2 = "One golden glance of what should be"
                      w_MessageBox30_2 = "CHORUS"
                      w_MessageBox30_3 = "EXIT"
                  
                  
                      # exit button action   
                      def exit(self):
                          print "exiting... one shaft of light will show the way..."
                          p1.terminate()  # terminate Flask by pressing on cancel
                          exit(1)
                  
                  
                      # do magic button action
                      def do_magic(self):
                          # your code goes here or maybe not
                          print "***** it's a kind of magic *************************"
                  
                  
                      # Kivy UI builder file
                      def build(self):
                          sm = Builder.load_string("""
                  
                  ScreenManager
                      MainScreen:
                          size_hint: 1, .7
                          auto_dismiss: False
                          title: app.w_MessageBox10_1       
                          title_align: "center"
                  
                          BoxLayout:
                              orientation: "vertical"
                              Label:
                                  text: app.w_MessageBox10_2
                              BoxLayout:
                                  orientation: "horizontal"
                                  spacing: 10
                                  size_hint: 1, .5
                                  Button:
                                      text: app.w_MessageBox30_2  # DO MAGIC
                                      on_press:
                                          app.do_magic()
                                  Button:
                                      text: app.w_MessageBox30_3  # EXIT
                                      on_press:
                                          app.exit()
                  
                  
                          """)
                  
                          return sm
                  
                  
                  if __name__ == '__main__':    
                  
                      # #CTRL+C signal handler
                      signal.signal(signal.SIGINT, signal_handler)
                      signal.signal(signal.SIGTERM, signal_handler)
                  
                      global p1
                      p1 = Process(target=start_Flask)    # assign Flask to a process
                      p1.start()                          # run Flask as process
                      Kivy().run()                        # run Kivy UI
                  

                  更新要通過(guò)在 Kivy 中按下按鈕來(lái)按需運(yùn)行 Flask,我使用下面的腳本.

                  UPDATE To run Flask on demand by pressing a button in Kivy I use the script below.

                  #!/usr/bin/python2.7 python2.7
                  # -*- coding: utf-8 -*-
                  
                  # kivy modules first, if not Kivy may cause problems
                  import kivy
                  from kivy.app import App
                  from kivy.lang import Builder
                  from kivy.uix.label import Label
                  from kivy.uix.floatlayout import FloatLayout
                  from kivy.uix.screenmanager import ScreenManager, Screen
                  kivy.require('1.10.0')
                  
                  # common modules
                  import sys
                  import os
                  import time
                  import signal
                  from multiprocessing import Process
                  
                  # Flask modules
                  from flask import Flask
                  
                  # wsgi (Web Server Gateway Interface) modules
                  import eventlet
                  from eventlet import wsgi
                  
                  # async server setup
                  app = Flask(__name__)
                  
                  def signal_handler(signal, frame):
                      print " CTRL + C detected, exiting ... "
                      exit(0)
                  
                  
                  # kivy gui classes ######################################################     
                  class MainScreen(Screen):
                      def __init__(self, **kwargs):
                          self.name="MAIN SCREEN"
                          super(Screen, self).__init__(**kwargs)
                  
                  class MainApp(App):
                      MainScreenTitle = "MainScreen title"
                      MainScreenLabel = "MainScreen label"
                      MessageButtonEnter = "START"
                      MessageButtonExit = "EXIT"
                  
                      def start_Flask(self):
                          print("Starting Flask...")
                          wsgi.server(eventlet.listen(('', 5000)), app)     # deploy as an eventlet WSGI server
                  
                      def stop(self):
                          print "terminating Flask and exiting..."
                          global p1
                          p1.terminate()
                          exit(1)
                  
                      def start(self):
                          print "starting Flask as process..."
                          global p1
                          p1 = Process(target=self.start_Flask) # assign Flask to a process
                          p1.daemon = True
                          p1.start()  #launch Flask as separate process
                  
                      def build(self):
                          sm = Builder.load_string("""
                  
                  ScreenManager
                      MainScreen:
                          size_hint: 1, .7
                          auto_dismiss: False
                          title: app.MainScreenTitle       
                          title_align: "center"
                  
                          BoxLayout:
                              orientation: "vertical"
                              Label:
                                  text: app.MainScreenLabel
                              BoxLayout:
                                  orientation: "horizontal"
                                  spacing: 10
                                  size_hint: 1, .5
                                  Button:
                                      text: app.MessageButtonEnter  # start app
                                      on_press:
                                          app.start()
                                  Button:
                                      text: app.MessageButtonExit  # exit app
                                      on_press:
                                          app.stop()
                  
                          """)
                  
                          return sm
                  
                  
                  # main ################################################
                  if __name__ == '__main__':
                  
                      #CTRL+C signal handler
                      signal.signal(signal.SIGINT, signal_handler)
                      signal.signal(signal.SIGTERM, signal_handler)
                  
                      MainApp().run()   # run Kivy app
                  

                  這篇關(guān)于如何同時(shí)運(yùn)行 kivy 和燒瓶應(yīng)用程序?的文章就介紹到這了,希望我們推薦的答案對(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)更改角色顏色)
                  • <small id='aVQW6'></small><noframes id='aVQW6'>

                    <tfoot id='aVQW6'></tfoot>
                      <tbody id='aVQW6'></tbody>

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

                            主站蜘蛛池模板: 日日草天天干 | 欧美日韩精品综合 | 欧美精品91| 久久99视频免费观看 | 成人综合在线视频 | 久久精品天堂 | 伊人超碰| 波多野结衣精品在线 | 欧美1区2区 | 99国内精品久久久久久久 | 国产一区二区在线播放 | 国产在线不卡 | 视频三区| 亚洲精品黄色 | 99在线免费观看视频 | 伊人久久综合 | 欧美亚洲另类在线 | 日韩国产一区二区三区 | 日韩av在线免费 | av在线视| 日本三级全黄三级a | 久久久久精 | 欧美成年黄网站色视频 | 综合久| 日本不卡一区二区三区 | 亚洲国产精品一区 | 亚洲网站在线观看 | 久久精品国产一区二区三区不卡 | 久久精品一区二区三区四区 | 久久精品免费 | 日韩视频精品在线 | 日本一区二区不卡视频 | 免费观看成人性生生活片 | 免费小视频在线观看 | 亚洲国产视频一区二区 | 黄色一级大片在线免费看产 | 久久新视频| 国精产品一区二区三区 | 91成人免费看片 | 欧美啊v在线观看 | 久久精品久久精品久久精品 |